📄 dlyfcns.hlp
字号:
{smcl}
{* 07apr2005}{...}
{cmd:help dlyfcns}
{hline}
{title:Title}
{p2colset 5 41 46 2}{...}
{p2col :{hi:[U] 24.3.1 Inputting time variables}}{hline 2} Functions
for inputting {cmd:%t} dates (translating dates from strings){p_end}
{title:Syntax}
{p 8 24 2}{it:...} {cmd:daily(}{space 5}{it:str_to_translate} {cmd:,} {it:pattern_str} [{cmd:,} {it:YYYY_value}]{cmd:)} {it:...}{p_end}
{p 8 24 2}{it:...} {cmd:weekly(}{space 4}{it:str_to_translate} {cmd:,} {it:pattern_str} [{cmd:,} {it:YYYY_value}]{cmd:)} {it:...}{p_end}
{p 8 24 2}{it:...} {cmd:monthly(}{space 3}{it:str_to_translate} {cmd:,} {it:pattern_str} [{cmd:,} {it:YYYY_value}]{cmd:)} {it:...}{p_end}
{p 8 24 2}{it:...} {cmd:quarterly(} {it:str_to_translate} {cmd:,} {it:pattern_str} [{cmd:,} {it:YYYY_value}]{cmd:)} {it:...}{p_end}
{p 8 24 2}{it:...} {cmd:halfyearly(}{it:str_to_translate} {cmd:,} {it:pattern_str} [{cmd:,} {it:YYYY_value}]{cmd:)} {it:...}{p_end}
{p 8 24 2}{it:...} {cmd:yearly(}{space 4}{it:str_to_translate} {cmd:,} {it:pattern_str} [{cmd:,} {it:YYYY_value}]{cmd:)} {it:...}{p_end}
{title:Remarks}
Function description:
{p 4 19 2}1st argument:{space 2}string to be translated{p_end}
{p 4 19 2}2nd argument:{space 2}{cmd:daily()}: permutation of {cmd:m}, {cmd:d}, {cmd:y}; e.g., {cmd:"mdy"} or {cmd:"dmy"}{p_end}
{p 18 19 2}{cmd:weekly()}: permutation of {cmd:w}, {cmd:y}:{space 2}{cmd:"wy"} or {cmd:"yw"}{p_end}
{p 17 19 2}{cmd:monthly()}: permutation of {cmd:m}, {cmd:y}:{space 2}{cmd:"my"} or {cmd:"ym"}{p_end}
{p 15 19 2}{cmd:quarterly()}: permutation of {cmd:q}, {cmd:y}: {cmd:"qy"} or {cmd:"yq"}{p_end}
{p 14 19 2}{cmd:halfyearly()}: permutation of {cmd:h}, {cmd:y}: {cmd:"hy"} or {cmd:"yh"}{p_end}
{p 18 19 2}{cmd:yearly()}: {cmd:"y"}{p_end}
{p 4 19 2}3rd argument:{space 2}optional; evaluates to numeric; specifies that 2-digit years in {it:str_to_translate} are to be interpreted as largest year that does not exceed {it:YYYY_value}{p_end}
{p 4 19 2}Returns:{space 7}{cmd:daily()}:{space 2}{cmd:%td} ({cmd:%d}) date or missing value{p_end}
{p 18 19 2}{cmd:weekly()}:{space 2}{cmd:%tw} date or missing value{p_end}
{p 17 19 2}{cmd:monthly()}:{space 2}{cmd:%tm} date or missing value{p_end}
{p 15 19 2}{cmd:quarterly()}:{space 2}{cmd:%tq} date or missing value{p_end}
{p 14 19 2}{cmd:halfyearly()}:{space 2}{cmd:%th} date or missing value{p_end}
{p 18 19 2}{cmd:yearly()}:{space 2}{cmd:%ty} date or missing value{p_end}
{p 4 11 2}Note: If the third argument is not specified, {cmd:y} in the
second argument can be optionally prefixed with two digits to indicate the
default century for two-digit years, e.g., {cmd:"md19y"} or {cmd:"dm20y"}.
{pstd}
See {help dates} and {help tdates} for an explanation of dates.
See {help dfmt} and {help tfmt} for an explanation of date and
time-series formats.
{pstd}
See {help datefcn} for a detailed explanation of {cmd:daily()}
(synonym for {cmd:date()}) and a full description of dealing with 2-digit
years. What is said there about the {cmd:date()} function applies to all the
functions above.
{title:Examples}
{pstd}
If the string variable {hi:bstr} contains strings like
"7-11-1948"
"07/11/1948"
"July 11, 1948"
"July11,1948"
"jul11-1948"
"7 11 1948"
...
{pstd}
then the following produces {hi:bdate} as the corresponding date variable:
{phang2}{cmd:. generate bdate = daily(bstr, "mdy")}{p_end}
{phang2}{cmd:. format bdate %td}
{pstd}
If the string variable {hi:mystr} contains strings like
"Jan 1989"
"jan1989"
"January1989"
"1 1989"
"1m1989"
"1/1989"
"janua 1989"
...
{pstd}
then the following produces {hi:mdate} as the corresponding monthly date
variable:
{phang2}{cmd:. generate mdate = monthly(mystr, "my")}{p_end}
{phang2}{cmd:. format mdate %tm}
{pstd}
If the string variable {hi:yqstr} contains strings like
"1970q3"
"1970 3"
"1970/3"
" 1970 quarter 3 "
...
{pstd}
then the following produces {hi:time} as the corresponding quarterly date
variable:
{phang2}{cmd:. generate time = quarterly(yqstr, "yq")}{p_end}
{phang2}{cmd:. format time %tq}
{title:Also see}
{psee}
Manual: {bf:[D] functions},{break}
{bf:[U] 24 Dealing with dates},{break}
{bf:[U] 24.3.1 Inputting time variables}
{psee}
Online: {help tdates},
{help tfmt};
{help datefcn},
{help dates},
{helpb format},
{help functions}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -