i want to loop to convert my strings data date starting by "d" into date format. But I have variables which have no data and it blocks my loop.
Here is my loop :
unab varlist : d*
foreach x in `varlist'{
gen `x'_2=date(`x',"YMD")
order `x'_2, after(`x')
format `x'_2 %dd_m_y
}
It doesn't work for variable that have 0 value (but it stops my loop...)
For example:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte d_1 str10 d_2 . "2020-07-17" . "2020-08-21" . "2020-07-16" . "2020-10-01" end
I want this with a loop :
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte d_1 float d_1_2 str10 d_2 float d_2_2 . . "2020-07-17" 22113 . . "2020-08-21" 22148 . . "2020-07-16" 22112 . . "2020-10-01" 22189 end format %dd_m_y d_2_2
Thanks you !
0 Response to Gen date variable with missing values
Post a Comment