Hi all,
I have a problem with converting an integer-type date (format %d) to long-type date (%10.0g), or vice versa. They just need to match such that I can create a new column that identifies when two dates match in two different columns or subtract one date column from the other and see when it is equal to 0.
I need to convert an integer date i.e. 14jan1970 to a date format: 700114
I have tried many different methods; however, the main issue is when converting the integer date to a number-type date, it becomes a 4-digit number. Unsure what to do here.
I also tried the below code and it just gave a new column with missing values:
tostring date, gen(datevar)
gen date2 = date(datevar, "YYMMDD")
format date2 %td
Can someone please advise on how to convert the dates such that I can subtract one from the other and find == 0?
Thank you all for your help!!
Related Posts with Convert Integer Date to Date Format
Alternatives to xtologit/xtoprobit for score as dependent variable and dummy as independent variableHi everyone, I’m new to Stata (using version 15.1 on Windows 10) and regard my statistical knowledge…
Extension files of OUT.file using X-12 ArimaHi, I am a novice user of Stata and in dire need of help. I am studying the monthly beer sales in bo…
Alternative analyses to xtologit/xtoprobit for score as dependent variable and dummy as independent variableHi everyone, I’m new to Stata (using version 15.1 on Windows 10) and regard my statistical knowledg…
OveridHello dear analysts I used to use overidentifying test by running the following HTML Code: ivregre…
Recoding rules based on string variableHello Statalist, I have a particularly unique, perhaps esoteric question. I am attempting to create…
Subscribe to:
Post Comments (Atom)
0 Response to Convert Integer Date to Date Format
Post a Comment