x cd /pub/data/acspums/Tools; %let pgm=application_disabledfarmers; filename pgm "&pgm..sas" ; /*---the request from Karen Funkenbusch with Missouri AgrAbility Program was to: locate the prevalence of disability for Missourians whose occupation falls within the field of agriculture (farming, fishing, or forestry). Because of the relatively small universe to be described we use the latest available 3-year data sets for the state. The user also indicated interest in breaking this down by age and sex. */ libname user '/SAS_temp/user'; libname acspums '/pub/data/acspums' access=readonly; title 'Tabulations of Disabled Persons Engaged in Agriculture Within Missouri'; title2 'Extracted Estimates Based on American Community Survey PUMS Data Covering the Period 2005 to 2007'; title3 'Universe: Disabled Persons in HHs Where 1 or More Persons Works in Agriculture'; footnote h=1 "Run on &sysdate &systime from setup in acspums/Tools/&pgm..sas"; options nodate; /* =======================Begin comment================ *---Step 1: Create a dataset of households that have 1 or more disabled persons age 18+ and 1 or more persons working in agriculture-; data disagghhs(keep=serialno); set acspums.moprecs073yr(in=inp keep=serialno agep pwgtp indp ds where=(agep ge 18) ) ; by serialno; if first.serialno then do; _agg=0; _disabled=0; end; retain _: ; if ds='1' then _disabled=1; if '0170' <= indp <= '0280' then _agg=1; if last.serialno then if _agg and _disabled then output; run; *---Step 2: Merge the H and P data with the just-created set of households of interest to create study data set--; data &pgm; merge disagghhs(in=keeper) acspums.mohrecs073yr(in=inh keep=serialno ags puma) acspums.moprecs073yr(in=inp keep=serialno agep sex pwgtp indp ds where=(agep ge 18) ) end=last; by serialno; if keeper; if ds='1'; if '0170' <= indp <= '0280' then works_inagg=1; else works_inagg=0; run; ======================End comment================== */ *----Step 3: Display tabulated results using proc tabulate---; proc format; value agegrp 18-64='18 to 64' 65-74='65 to 74' 75-high='75+'; value $sex 1='Male' 2='Female'; value $ags 1,2='$ 0 - $ 999' 3='$ 1000 - $ 2499' 4='$ 2500 - $ 4999' 5='$ 5000 - $ 9999' 6='$10000+'; value $indp 0170='CROP PRODUCTION' 0180='ANIMAL PRODUCTION' 0190='FORESTRY EXCEPT LOGGING' 0270='LOGGING' 0280='FISHING, HUNTING, & TRAPPING' 0290='SUPPORT ACTIVITIES FOR AG & FORESTRY' other='Other ind not Ag'; run; ods html file="/pub/reports/temp/&pgm..html"; proc tabulate data=&pgm; class ags agep sex indp; var works_inagg ; freq pwgtp; label agep='Age' ags='Agricultural sales' works_inagg='Works in Ag'; format agep agegrp. ags $ags. sex $sex. indp $indp. ; table all agep ags indp, all sex (all sex)*works_inagg*(sum='N'*f=comma7. mean='%'*f=percent6.); run; ods html close;