x cd /pub/data/sf32000/Tools; %let pgm=aggsf3; filename pgm "&pgm..sas"; /*--This program will aggregate a sf32000 dataset using the %agg macro. It will handle means and medians. The %median macro is used to estimate median from distributions. John Blodgett, OSEDA, U. of Missouri Under contract with the Missouri Census Data Center. August, 2002. ---*/ filename mprint "&pgm._mprint.sas"; *--If following statement is not a comment then SAS will write the expanded macro-generate code from bigstep macro to the mrpint file, (see previous stmt). This can then be %include d in subsequent run. Good debugging tool-; *options mfile ; options mprint; libname sf32000 '/pub/data/sf32000'; libname sf3 (sf32000); *<--alternate name--; libname user '/tmp/scratch/user'; title "&pgm: Sample Setup to Aggregation 2000 sf3 Datasets"; title2 'Delaware Using Census Tracts as Entities to Aggregate'; options compress=yes msglevel=i ; *-------There are 3 datasets to be aggregated: the ph set with P and H tables, the phct set with (most) PCT and HCT tables, & the phctr set with PCT(r) and HCT(r) tables, where (r) is an alpha race code. We aggregate the 3 sets separately, creating 3 output sets. The parm &setout specifies the base name of the output sets, to which we append "ph", "phct" and "phctr". -------*; %macro preexit; %*--code used in pre processing steps to create any new variables or other special processing--; %*--any new character variables created other than those in aggby list must be mentioned here in a keep statement. Numeric variables are automatically kept. -; where SumLev='050' and geocomp='00'; *<----; *where SumLev='070'; %mend preexit; %macro postexit; * length SumLev $3 geocode $16 Areaname $90; select (_lvl_); *<=====Very custom stuff, needs to be redone for each case=====; when(1) do; SumLev='390'; *<---; geocode=state||'-'||msacmsa; areaname=put(msacmsa,$metro.); *SumLev='160'; *geocode=state||'-'||placefp; *Length _arg $7; * _arg=state||placefp; *areaname=put(_arg,$fplace.); *drop _arg; end; when(2) do; SumLev='040'; geocode=state; areaname=put(state,$state.); end; otherwise ; end; %mend postexit; %aggsf3(settypes=ph phct phctr, setin=de, setout=demsas, aggby=state msacmsa, agglvl=2, templib=user, steps= pre agg post, idlens=%str(SumLev $3 geocode $16 Areaname $90 msacmsa $4), report=1) ; %*include mprint/source2; %include sascode(notify);