x cd /pub/data/acspums/Tools; %let pgm=application_minfamswkids; filename pgm "&pgm..sas"; *---acspums Excample. jgb, 9/2009. Client: Elizabeth Cogswell, Foundations Relations, MU Data requested: data on households/families in Columbia by race/ethnic group? ...[esp] at black families, although if the data exists for Hispanic/Latino families it would be good to have that as well. It would be even better if there were data about families/households with school-age children. Specifically, the foundation wants to know: 1. The percentage of these families who have income at or below $42,400 for a family of four: (200% of federal poverty level) 2. The percentage of these families who are single-parent households 3. Of the single-parent households in #2 above, an estimate of the percentage that are female head of households 4. Approximate percentage of the heads of these households who have a high school education or less. We'll approximate Columbia using Boone county (= PUMA 00600). And we'll use the 3-year 2005-2007 data to get better statistical reliability since we are working with rather small universes here. ----*; %libname (acspums); libname temp '/pub/data/temp'; *<---"Permanent temporary" data. Keep until project is completed. Lets us save intermediate results-; libname user '/SAS_temp/user'; *------Step 1: Pull the data subset. Filter for the relevant household cases and keep and/or derived needed variables----; /* =======================Begin comment================ data temp.&pgm.h; *--use the program name as the name of the temp data set to make it easy to trace back if ever needed--; set acspums.mohrecs073yr (keep=serialno puma wgtp type hupac np fes ); where puma='00600' and type='1' and hupac in ('2','3'); * -- in Boone co, family HH, with school age children (6-17) --*; single_parent=(fes in ('5','6','7','8')); *--we have already determined kids are present. So these categories work.-; single_parentF=(fes in ('7','8')); label single_parent='Single Parent Household' single_parentF='Female-headed single Par HH'; run; data temp.&pgm.p; set acspums.moprecs073yr(keep=serialno sporder puma pwgtp hisp racwht racblk povpip schl); where puma='00600' and sporder=1 and ( (hisp ne '01') or (racblk='1') or (racwht='1') ); *--sporder=1 means head of HH. Must be hispanic or black/wht (alone or in comb)-; drop sporder ; run; data temp.merged; *<---combine the 2 data sets, keeping only cases where it passed both sets of filters (HH and Person)--; merge temp.&pgm.h(in=inh) temp.&pgm.p(in=inp); by serialno; if inh and inp; *---Create new poverty variable based on whether they are at or below twice the pov level--; poorish=(povpip <= 200); label poorish="<= 200% of Pov Level"; HSorLess=(schl le '09'); label HSorLess='High School or less'; run; ======================End comment================== */ data tabin; set temp.merged; if hisp ne '01' then do; FamType='h'; output; end; if racblk='1' then do; Famtype='b'; output; end; if hisp='01' and racwht='1' then do; Famtype='w'; output; end; run; proc format; value $famtype 'h'='Hispanic' 'b'='African American' 'w'='White/Non Hispanic'; value yesno 1='Yes' 0='No '; run; title "Data for Selected Minority Households With School Age Children in Boone County, MO"; title2 "Based on American Community Survey PUMS Data, 2005-2007"; footnote .h=1 "Report Produced by OSEDA, U of Missouri from setup in acspums/Tools/&pgm..sas"; %macro tabit; %do wt=0 %to 1; proc tabulate data=tabin; class puma famtype ; var single_parent: poorish hsorless; *label hisp='Hispanic' racblk='Black'; format famtype $famtype. puma $mopuma. ; label puma='PUMA'; %if &wt %then %do; ods html file="&pgm..weighted.html"; title3 "Using Household Weight"; freq wgtp; *<---we use the household weight rather than the head of household person weight--; %end; %else %do; ods html file="&pgm..unweighted.html"; title3 "Without Using Household Weight"; %end; table puma, famtype, all *f=comma7. poorish *(sum="HHs"*f=comma7. mean="Pct"*f=percent5.) hsorless *(sum="HHs"*f=comma7. mean="Pct"*f=percent5.) single_parent *(sum="HHs"*f=comma7. mean="Pct"*f=percent5.) single_parentF*(sum="HHs"*f=comma7. mean="Pct"*f=percent5.) ; run; ods html close; %end; %*---do wt loop--; %mend tabit; options mprint spool; %tabit;