x cd /pub/data/pums2000/Tools; %let pgm=unistats; filename pgm "&pgm..sas"; *--Genrate univariate stats report on pums1 datasets using proc tabulate. Use custom formats to display the results. John Blodgett, OSEDA, U. of Missouri Outreach & Extension Under a contract with the Missouri Census Data Center. May, 2003. --*; %let state=29; %let stab=mo; %let statenm=Missouri; libname pums2000 '/pub/data/pums2000'; libname user '/SAS_temp/user'; title "PUMS 1% Univariate Statistics for &statenm"; %*** include 'valfmats.sas' ; options fmtsearch=(work user pums2000.formats1 sasctlgs.formats library.formats); proc format; *--create a temp format code to override the one on the formats library--; *--This format indicates we just care about owner or renter, we do not care about mortgag status or whether cash rent is paid.--; value $tenure '1','2'='Owned' '3','4'='Rented'; run; *---We sum the various income figures to the household total. And we save the age of the head of HH--; data raw; set pums2000.&stab.1; where tenure ne '0'; *--filters group quarters and vacant units--; by serialno notsorted; if first.serialno then agehead=age; retain agehead; format tenure $tenure.; keep hweight tenure serialno puma1; keep condfee elec gas insamt mhcost mrt1amt mrt2amt oil rent water agehead incint incoth incpa incret incse incss incssi inctot incws ; array Hvars(*) condfee elec gas insamt mhcost mrt1amt mrt2amt oil rent water; if not first.serialno then do; *--see H variables to missing on all but first appearance to avoid multiple summing in next step-; do _i=1 to dim(Hvars); Hvars(_i)=.; end; end; format condfee condfee. elec elec. gas gas. insamt insamt. mhcost mhcost. mrt1amt mrt1amt. mrt2amt mrt2amt oil oil. rent rent. water water. agehead age. incint incint. incoth incoth. incpa incpa. incret incret. incse incse. incss incss. incssi incssi. inctot inctot. incws incws. ; drop _:; run; proc summary noprint nway data=raw; class serialno; var condfee elec gas insamt mhcost mrt1amt mrt2amt oil rent water agehead incint incoth incpa incret incse incss incssi inctot incws ; id tenure puma1; id hweight; *<---Need to pass this along to next step to use it as a weight variable. We originally used it as a weight variable in this step and it produced silly results.---; output out=hhsums(rename=(_freq_=Nhhs) drop=_type_) sum=; run; proc tabulate data=hhsums; weight hweight; *<---we already did the weighting in the proc summary step---; class tenure puma1; format tenure $tenure.; var condfee elec gas insamt mhcost mrt1amt mrt2amt oil rent water agehead incint incoth incpa incret incse incss incssi inctot incws ; format condfee condfee. elec elec. gas gas. insamt insamt. mhcost mhcost. mrt1amt mrt1amt. mrt2amt mrt2amt oil oil. rent rent. water water. age age. incint incint. incoth incoth. incpa incpa. incret incret. incse incse. incss incss. incssi incssi. inctot inctot. incws incws. ; title2 'Some Stats by Tenure for Household Indicators'; table /* all puma1, */ tenure*(condfee elec gas insamt mhcost mrt1amt mrt2amt oil rent water agehead incint incoth incpa incret incse incss incssi inctot incws), n min max mean median;