I have the attached .csv file with date format in %tm format, which looks like:
When I try to run a regression on a specific duration of the sample I get the error:
The manual seem a little bit cryptic.
I think this has something to do with the variable being imported in a string format, since in the properties of the variables I see:
I tried to generate a new variable with:
but with no success.
How do I run the conditional regression I want?
Reproducible example:
Code:
MONTH,Y,X 2000m1,0.0979083,-0.1030651 2000m10,-0.0543795,0.1151973 2000m11,-0.0050536,0.1228735 2000m12,0.0302205,0.0029895
Code:
regress y x if month>=tm(2001m1) & month<=tm(2006m9) type mismatch r(109);
I think this has something to do with the variable being imported in a string format, since in the properties of the variables I see:
Code:
Name: month Label: MONTH Type: str7 Format:%9s
Code:
gen YEARMONTH = date(MONTH, "YM")
How do I run the conditional regression I want?
Reproducible example:
Code:
insheet using stata-stack.csv save stata-stack.dta regress y x if month>=tm(2001m1) & month<=tm(2006m9)
Comment