Hello,
I am using Stata15. I have several variables that indicate a start date or an end date for a particular project. They were imported into stata as string variables.
Using just one of the variables, I was able to make this work:
generate addstory_sdate= monthly(addstory_s, "MY", 2019)
format addstory_sdate %tmmonthCCYY
order addstory_sdate, after(addstory_s)
However, when I tried to use a foreach loop to run through all of my date variables, I couldn't get it to work. I think there is a problem with the format command. This is the code I'm using:
foreach x of varlist addstory_s addstory_c addroom_s addroom_c {
generate `x'date = monthly(`x', "MY", 2019)
format `x'date %tmmonthCCYY
order `x'date, after(`x')
}
I would appreciate any advice or direction.
I am using Stata15. I have several variables that indicate a start date or an end date for a particular project. They were imported into stata as string variables.
Using just one of the variables, I was able to make this work:
generate addstory_sdate= monthly(addstory_s, "MY", 2019)
format addstory_sdate %tmmonthCCYY
order addstory_sdate, after(addstory_s)
However, when I tried to use a foreach loop to run through all of my date variables, I couldn't get it to work. I think there is a problem with the format command. This is the code I'm using:
foreach x of varlist addstory_s addstory_c addroom_s addroom_c {
generate `x'date = monthly(`x', "MY", 2019)
format `x'date %tmmonthCCYY
order `x'date, after(`x')
}
I would appreciate any advice or direction.
Comment