I have two variables: one is day (i.e. 1,2.......365/366) and other is rainfall. I want to convert that day in to date in DMY. I would appreciate your help. Thank you in advance.
-
Login or Register
- Log in with
v11 | v12(rainfall) |
1 | 0.0 |
2 | 1.2 |
3 | 2.3 |
3.3 | |
365 | 4.4 |
1 | 3.8 |
2 | 0.0 |
3 | |
365/366 | 14.5 |
cd "F:\climate data\New folder" local filelist: dir . files "*.dta" clear gen source = "" foreach f of local filelist { append using "`f'" replace source = "`f'" if mi(source) } split v1, limit(2) destring v11 generate year = 2006 // subtract 1 from the year each time the day goes back to 1 AND the source is the same // for the first observation from each new source, the year will remain 2006 // and the countdown starts over replace year = cond(v11==1,year[_n-1]-1,year[_n-1]) if _n>1 & source[_n]==source[_n-1] generate dailydate = mdy(1,1,year) + v11 - 1 format dailydate %td
Comment