* * CHAPTER 3 * Page 86 * open data ch03_cps.xls data(format=xls,org=columns) 1 20999 a_sex year ahe04 * do test=1992,2004,4 * * The SMPL option is used to restrict an analysis to a subset of the * data. Here, the first STATS will apply to the entries where a_sex is * 1 (== is used to test for equality), and year is the current value of * test. The second stats restricts it to the sample where a_sex is 2 and * the year is test. After each, we pull out the mean, variance and # of * observations (%nobs). * stats(smpl=a_sex==1.and.year==test) ahe04 compute m_m=%mean,v_m=%variance,n_m=%nobs stats(smpl=a_sex==2.and.year==test) ahe04 compute m_f=%mean,v_f=%variance,n_f=%nobs * * This computes the difference in the means and the standard error of * the difference in the means. Lower and upper are constructed as the * upper and lower 95% limits. * compute delta=m_m-m_f,sdelta=sqrt(v_m/n_m+v_f/n_f) compute lower=delta-1.96*sdelta,upper=delta+1.96*sdelta * * This displays the information used in the table * disp "Year" test disp "Males" m_m sqrt(v_m) n_m disp "Females" m_f sqrt(v_f) n_f disp "Differences" delta sdelta lower "-" upper end do test * * This is the same as the above, but using the REPORT instruction to arrange the * data in a table. * report(action=define) report(atrow=1,atcol=2,tocol=4,span) "Men" report(atrow=1,atcol=5,tocol=7,span) "Women" report(atrow=1,atcol=8,tocol=11,span) "Difference, Men vs Women" report(atrow=2,atcol=1) "Year" "Mean" "S.E" "Nobs" "Mean" "S.E." "Nobs" "Mean" "S.E." report(atrow=2,atcol=9,tocol=11,span) "95% CI" do test=1992,2004,4 stats(noprint,smpl=a_sex==1.and.year==test) ahe04 compute m_m=%mean,v_m=%variance,n_m=%nobs stats(noprint,smpl=a_sex==2.and.year==test) ahe04 compute m_f=%mean,v_f=%variance,n_f=%nobs * * This computes the difference in the means and the standard error of * the difference in the means. Lower and upper are constructed as the * upper and lower 95% limits. * compute delta=m_m-m_f,sdelta=sqrt(v_m/n_m+v_f/n_f) compute lower=delta-1.96*sdelta,upper=delta+1.96*sdelta report(row=new,atcol=1) test m_m sqrt(v_m) n_m m_f sqrt(v_f) n_f delta sdelta lower "-" upper end do test * * This formats all the non-integer fields to two decimal places * report(action=format,picture="*.##") report(action=show) report(action=show,window="Table 3.1 Trends in Hourly Earnings in the United States")