Hi,
I just started to learn Stata today and I can`t get my do.file to run.
I am trying to run http://masteringmetrics.com/wp-conte...9_hicompare.do
and I get the error code r(111):
. u NHIS2009_clean, clear
.
. * select non-missings
. keep if marradult==1 & perweight!=0
(50,662 observations deleted)
. by serial: egen hi_hsb = mean(hi_hsb1)
(207 missing values generated)
. keep if hi_hsb!=. & hi!=.
(207 observations deleted)
. by serial: egen female = total(fml)
. keep if female==1
(31 observations deleted)
. drop female
.
. * Josh's sample selection criteria
. gen angrist = ( age>=26 & age<=59 & marradult==1 & adltempl>=1 )
. keep if angrist==1
(9,613 observations deleted)
. // drop single-person HHs
. by serial: gen n = _N
. keep if n>1
(1,331 observations deleted)
.
. * count of husbands by HI status
. tab hi if fml==0 [ aw=perweight ]
hi | Freq. Percent Cum.
------------+-----------------------------------
0 | 1,281.4929 13.64 13.64
1 | 8,113.5071 86.36 100.00
------------+-----------------------------------
Total | 9,395 100.00
.
. * mean comparisons for husbands
. foreach var in hlth nwhite age yedu famsize empl inc {
2. qui reg `var' hi if fml==0 [ w=perweight ], robust
3.
. * means and standard devs
. qui sum `var' if hi==0 & fml==0 [ aw=perweight ]
4. local m0 =r(mean)
5. local sd0 =r(sd)
6. qui sum `var' if hi==1 & fml==0 [ aw=perweight ]
7. local m1 =r(mean)
8. local sd1 =r(sd)
9.
. if "`var'"=="hlth" {
10. outreg2 hi using hicompare_hsb, replace excel noaster adec(2) dec(2
> ) bdec(2) sdec(2) ///
> addstat("Mean no HI",`m0',"SD no HI",`sd0',"Mean HI",`m1',"SD HI",`sd1
> ')
11. }
12. if "`var'"!="hlth" {
13. outreg2 hi using hicompare_hsb, append excel noaster adec(2) dec(2)
> bdec(2) sdec(2) ///
> addstat("Mean no HI",`m0',"SD no HI",`sd0',"Mean HI",`m1',"SD HI",`sd1
> ')
14. }
15. }
hicompare_hsb.xml
dir : seeout
hicompare_hsb.xml
dir : seeout
hicompare_hsb.xml
dir : seeout
hicompare_hsb.xml
dir : seeout
hicompare_hsb.xml
dir : seeout
hicompare_hsb.xml
dir : seeout
SD not found
r(111);
end of do-file
r(111);
To access the data file: http://masteringmetrics.com/resources/ (Table 1.1).
If anyone could help me out, I would be really grateful.
I just started to learn Stata today and I can`t get my do.file to run.
I am trying to run http://masteringmetrics.com/wp-conte...9_hicompare.do
and I get the error code r(111):
. u NHIS2009_clean, clear
.
. * select non-missings
. keep if marradult==1 & perweight!=0
(50,662 observations deleted)
. by serial: egen hi_hsb = mean(hi_hsb1)
(207 missing values generated)
. keep if hi_hsb!=. & hi!=.
(207 observations deleted)
. by serial: egen female = total(fml)
. keep if female==1
(31 observations deleted)
. drop female
.
. * Josh's sample selection criteria
. gen angrist = ( age>=26 & age<=59 & marradult==1 & adltempl>=1 )
. keep if angrist==1
(9,613 observations deleted)
. // drop single-person HHs
. by serial: gen n = _N
. keep if n>1
(1,331 observations deleted)
.
. * count of husbands by HI status
. tab hi if fml==0 [ aw=perweight ]
hi | Freq. Percent Cum.
------------+-----------------------------------
0 | 1,281.4929 13.64 13.64
1 | 8,113.5071 86.36 100.00
------------+-----------------------------------
Total | 9,395 100.00
.
. * mean comparisons for husbands
. foreach var in hlth nwhite age yedu famsize empl inc {
2. qui reg `var' hi if fml==0 [ w=perweight ], robust
3.
. * means and standard devs
. qui sum `var' if hi==0 & fml==0 [ aw=perweight ]
4. local m0 =r(mean)
5. local sd0 =r(sd)
6. qui sum `var' if hi==1 & fml==0 [ aw=perweight ]
7. local m1 =r(mean)
8. local sd1 =r(sd)
9.
. if "`var'"=="hlth" {
10. outreg2 hi using hicompare_hsb, replace excel noaster adec(2) dec(2
> ) bdec(2) sdec(2) ///
> addstat("Mean no HI",`m0',"SD no HI",`sd0',"Mean HI",`m1',"SD HI",`sd1
> ')
11. }
12. if "`var'"!="hlth" {
13. outreg2 hi using hicompare_hsb, append excel noaster adec(2) dec(2)
> bdec(2) sdec(2) ///
> addstat("Mean no HI",`m0',"SD no HI",`sd0',"Mean HI",`m1',"SD HI",`sd1
> ')
14. }
15. }
hicompare_hsb.xml
dir : seeout
hicompare_hsb.xml
dir : seeout
hicompare_hsb.xml
dir : seeout
hicompare_hsb.xml
dir : seeout
hicompare_hsb.xml
dir : seeout
hicompare_hsb.xml
dir : seeout
SD not found
r(111);
end of do-file
r(111);
To access the data file: http://masteringmetrics.com/resources/ (Table 1.1).
If anyone could help me out, I would be really grateful.
Comment