x cd /pub/data/sf32000/Tools; %let pgm=aggsf3_samples; filename pgm "&pgm..sas"; /*--the aggsf3.sas module is the template for doing aggregation of sf32000-type datasets. This module is intended to serve as a set of examples of how one can make use of the basic aggsf3 macro. John Blodgett, OSEDA, U. of Missouri Under contract with the Missouri Census Data Center. August, 2002. ---*/ options NOmprint; libname sf32000 '/pub/data/sf32000'; libname sf3 (sf32000); *<--alternate name--; libname user '/tmp/scratch/user'; title "&pgm: Sample Setups for Aggregating 2000 sf3 Datasets"; options compress=yes msglevel=i ; /* *************************Example 1: Aggregate County Data to Regions Per a "Correlation List" which assigns each county to a district (purely imaginary). We even split one of the counties, allocating 60% to one didstrict and 40% to another. We use Delaware data because there is so little of it. */ data corrlst; input county $5. +1 Region $2. afact; lines; 10001 R1 1 10003 R1 .6 10003 R2 .4 1005 R3 1. run; *----create the input ph dataset by merging the original set with the correlation list, attaching the Region and afact codes.--; data deph; merge %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);