Stata Technical Bulletin
Example
The following example shows the use of a few of the commands on a short artificial data set.
. list
m |
У | |
1. |
2 |
1992 |
2. |
2 |
1994 |
3. |
4 |
1994 |
4. |
7 |
1994 |
ε. |
12 |
1994 |
. Iastbday m y, generate (Ibday)
. list
m |
У |
Ibday | ||
1. |
2 |
1992 |
28 | |
2. |
2 |
1994 |
28 | |
3. |
4 |
1994 |
29 | |
4. |
7 |
1994 |
29 | |
ε. |
12 |
1994 |
30 | |
mdytodow m Ibday у. |
, gen(dow) | |||
list | ||||
m |
У |
Ibday |
do w | |
1. |
2 |
1992 |
28 |
Fri. |
2. |
2 |
1994 |
28 |
Mon. |
3. |
4 |
1994 |
29 |
Fri. |
4. |
7 |
1994 |
29 |
Fri. |
ε. |
12 |
1994 |
30 |
Fri. |
list, |
nolabel | |||
m |
У |
Ibday |
do w | |
1. |
2 |
1992 |
28 |
ε |
2. |
2 |
1994 |
28 |
1 |
3. |
4 |
1994 |
29 |
ε |
4. |
7 |
1994 |
29 |
ε |
ε. |
12 |
1994 |
30 |
ε |
. describe
Contains data
Obs : |
ε |
(max= |
8088) |
Vars : |
4 |
(max= |
99) |
Width: |
12 |
(max= |
200) |
1. m |
float '∕09.Og | ||
2. y |
float |
7.9.0g | |
3. Ibday |
int |
7.8.0g | |
4. do w |
int |
7.8.0g |
Dayslab |
Sorted by:
Note that the new variable dow is an integer, but has been given the label Dayslab.
Each of these date commands may also be used in immediate form. To use the command in immediate form, simply type
the name of the command along with the numbers or strings for the day, month, or year you want converted. The command
will display its results to the screen as well as saving them in the global macros S_l-S_4.
Example
. lastday 2 1992
29
Saturday, February 29, 1992
. disp_s
S_l: 29
S_2: Saturday
S_3: Sat
S_4: Sat.
. today
July 1, 1994