Hi
I am fairly new to Stata, currently completing my dissertation on Stata 17.
I am struggling to arrange my dataset when I import my data from excel to stata (I have 132 observations).
Stuck on the date variable.
I used these codes:
. tostring date, replace
date was int now str5
. gen day=substr(date,1,2)
. gen month=substr(date, 4, 2)
. gen year=substr(date, 7, 4)
(132 missing values generated)
. destring day, replace
day: all characters numeric; replaced as byte
. destring month, replace
month: all characters numeric; replaced as byte
. destring year, replace
year: all characters numeric; replaced as byte
(132 missing values generated)
. gen time=mdy(month, day, year)
(132 missing values generated)
. gen newdate=qofd(time)
(132 missing values generated)
. format newdate %tq
. tsset newdate, q
Time variable: newdate, . to .
Delta: 1 quarter
The problem is that when I generate year variable, I have 132 missing values generated, so when I destring year, generate time... The missing values generated are not letting me continue.
I have been at this for many days, this is my last hope at the moment.
Thank you in advance!
I am fairly new to Stata, currently completing my dissertation on Stata 17.
I am struggling to arrange my dataset when I import my data from excel to stata (I have 132 observations).
Stuck on the date variable.
I used these codes:
. tostring date, replace
date was int now str5
. gen day=substr(date,1,2)
. gen month=substr(date, 4, 2)
. gen year=substr(date, 7, 4)
(132 missing values generated)
. destring day, replace
day: all characters numeric; replaced as byte
. destring month, replace
month: all characters numeric; replaced as byte
. destring year, replace
year: all characters numeric; replaced as byte
(132 missing values generated)
. gen time=mdy(month, day, year)
(132 missing values generated)
. gen newdate=qofd(time)
(132 missing values generated)
. format newdate %tq
. tsset newdate, q
Time variable: newdate, . to .
Delta: 1 quarter
The problem is that when I generate year variable, I have 132 missing values generated, so when I destring year, generate time... The missing values generated are not letting me continue.
I have been at this for many days, this is my last hope at the moment.
Thank you in advance!
Comment