Hi,
I am new STATA user and I have a question about my loops that unfortunately don't work. I use STATA 15.
I work on a panel data and want to run regression for small and big in each year.
In the first step I generate labels for small medium and large companies and it works
gen small =.
gen large =.
gen size =.
forvalues i = 1962(1)2017 {
summ mvaluemill if pyear==`i' , detail
di `i'
replace small = r(p25) if pyear==`i'
replace large = r(p75) if pyear==`i'
replace size = 0 if mvaluemill < small & pyear==`i'
replace size = 1 if mvaluemill > small & mvaluemill < large & pyear==`i'
replace size = 2 if mvaluemill > large & pyear==`i'
However, in the second step when I want to run regressions for small companies in each year using the following loop:
forvalues i = 1962(1)2017 {
reg prc atpr capxpr ceqpr chpr cogspr dvcpr intanpr ibpr oancfpr revtpr spipr xadpr xrdpr xsgapr revgrowpr ocipr if pyear==`i' & size==0
}
STATA responds:
no observations
r(2000);
Any help or comments much appreciated. Sorry If I missed any important information.
Thanks!
I am new STATA user and I have a question about my loops that unfortunately don't work. I use STATA 15.
I work on a panel data and want to run regression for small and big in each year.
In the first step I generate labels for small medium and large companies and it works
gen small =.
gen large =.
gen size =.
forvalues i = 1962(1)2017 {
summ mvaluemill if pyear==`i' , detail
di `i'
replace small = r(p25) if pyear==`i'
replace large = r(p75) if pyear==`i'
replace size = 0 if mvaluemill < small & pyear==`i'
replace size = 1 if mvaluemill > small & mvaluemill < large & pyear==`i'
replace size = 2 if mvaluemill > large & pyear==`i'
However, in the second step when I want to run regressions for small companies in each year using the following loop:
forvalues i = 1962(1)2017 {
reg prc atpr capxpr ceqpr chpr cogspr dvcpr intanpr ibpr oancfpr revtpr spipr xadpr xrdpr xsgapr revgrowpr ocipr if pyear==`i' & size==0
}
STATA responds:
no observations
r(2000);
Any help or comments much appreciated. Sorry If I missed any important information.
Thanks!
Comment