I am gettings problems when I encode a date variable, to explain my problem I will use this example:
Code:
webuse wpi1, clear list in 1/10 +--------------------------+ | wpi t ln_wpi | |--------------------------| 1. | 30.7 1960q1 3.424263 | 2. | 30.8 1960q2 3.427515 | 3. | 30.7 1960q3 3.424263 | 4. | 30.7 1960q4 3.424263 | 5. | 30.8 1961q1 3.427515 | |--------------------------| 6. | 30.5 1961q2 3.417727 | 7. | 30.5 1961q3 3.417727 |
Code:
format t %tdd/N/CY
Code:
generate date = string(t, "%tdd/N/CY") encode date, gen(date2)
Array
When i save graph I use values (v) and not labels (vl) to avoid error with slash in directory folder. (its a fool graph I know, just one example):
Code:
levelsof date2, local(levels) local nombre: value label date2 foreach v of local levels { local vl: label `nombre' `v' line wpi date2 if date2 == `v', ti(`vl') } graph export "C:\User\`v'.png", replace
I know that I could use
Code:
label define order 1 "1/01/1960"... encode date, gen(date2) label(order)
Please any comments I would grateful
Thanks in advance
Rodrigo.
0 Response to Problem encoding dates: unordered value
Post a Comment