%macro aggsf3( revdate=6/17/2003 2:10PM, /* date this macro code last revised */ /* aggregate 1 or more sf32000 data sets. This macro will generate complete pre / agg / post steps to carry out the aggregation for up to 3 datasets -- based on the settypes parm. Invokes the %agg and %median macros which must be excplicitly included prior to invocation or accessible via mautosource feature. Several customizing macros must be defined prior to invoking this macro. These handle custom pre- and post-processing steps. These macros must have the names preexit and postexit . They can reference the global variable _type with value in (ph phct phctr) to vary code according to dataset type. Revisions: Are denoted by comments in the text with data modified flagged with *<== 8-31-02: Two changes per problems reported by Ellen Cryan. Corrected name of agg macro var from afact to facvar. Implementing the idlens parm. Was never used before. ~6/17/03 or before: added idvs & compress parms. Usage Note: The aggregated values for the sampling percentages h4i1 and h4i2 will not be totally accurate when areas being aggregated contain cases of no units (occupied or vacant) being sampled even though there are such units in the area. In these case we cannot derive the 100% count of such units, which we need to do in order to weight the percentages during aggregation. Users might just want to set these variables to missing on aggregated datasets. *<==== ******* */ settypes=ph phct phctr, /* dataset types to aggregate. If you just need to aggregate the ph dataset then specify settypes=ph and the macro will only generate 1 aggregation suite. */ setinlib=sf3, /* Required. libref portion of input data set */ setin=, /* REQUIRED. This is usually a state postal abbreviation. The complete input set is expected to be in sf3.&setin&settype , where &settype takes on the values ph, phct and phctr in order, per the settypes parm. (Assumes setinlib parm has default value of sf3. Actually the input set is &setinlib..&setin.&settype) */ setoutlib=sf3, /* libref portion of output dataset(s) */ setout=, /* the names of the output datasets will be derived by using this value and writing to &setoutlib..&setout&settype , where &settype takes on the values ph, phct and phctr in order, per the settypes parm. */ aggby=, /* *--REQUIRED. List of variables to aggregate by. Usually geocodes. These can be assigned in preexit macro. */ idvs=, /* if specified the value of this parm gets passed as the value of the idvars parm to the agg macro */ compress=yes, /* compress option for output datasets. Only valid values are yes and no . */ idlens=SumLev $3 geocode $16 AreaName $90, /* Specifies names and lengths of ID variables on output datasets. The value is a SAS length statement but without the keyword and semicolon. It will normally include your aggby variables. geocode and areaname are commonly calculated in a postexit routine to customize output. A SumLev variable on output is a really good idea. You will probably have to make up your own code unless aggregating to a level recognized by the Bureau. */ agglvl=1, /* if aggby has multiple variables then agglvl can be used to specify how many levels of aggregation to do. For example, if aggby=state zone county and agglvl=2 then aggregation will be done at the state-zone level as well as at the full state-zone-county level. If agglvl=3 were specified there would also be a state level summary done. */ templib=work, /* library where temp (1-level) sets are stored. Specify templib=user if you have defined a user libref. If you don't know what this means then you do not have to do anything - the default will work. */ steps=pre agg post, /* use this while debugging to specify which of the 3 steps need to be run. You need to have a libname user to preserve the temporary sets created in each step for this to work. Or you could run it one step at a time within an interactive session. */ afact=, /* If the input dataset has an allocation factor on it that is to be used by agg then specify the name of that variable here */ report=0); /* specify report=1 if you generate a level 040 summary and want to generate a comparison report to check on validity of the aggregation. */ %put *** aggsf3 macro, revised &revdate , Begin execution with: ; %put setin:&setin ; %put setout:&setout; %put settypes:&settypes ; %put aggby:&aggby; %local itype type UPtype i; %let itype=1; %let type=%scan(&settypes,&itype); %do %while(&type ne %str()); %let UPtype=%upcase(&type); %put ***Begin processing of set type &UPtype ***; %if %index(&steps,pre) %then %do; *<----------------Pre-agg step--------------------------; data aggin&UPtype ; set &setinlib..&setin.&type; %preexit %*<==================================================================; %if &type=ph %then %do; *--Calculate 2 new universe variables needed for aggregating. These are the 100 pct counts for occupied and vacant hus-; if H4i1 then H3i2=100*(H2i2/H4i1); *--100% count of occ units is occ units sampled divided by pct occ units sampled-; if H4i2 then H3i3=100*(H2i3/H4i2); *--100% count of vac units is vac units sampled divided by pct vac units sampled-; label H3i2='100% Count of Occupied hus (derived)' H3i3='100% Count of Vacant units (derived)'; drop PCT; *--this was a little flag var we set which is irrelevant after aggregation-; %end; keep SumLev &idvs &aggby _numeric_; *<----specify id vars and then Keep all the table cells with _numeric_; run; *--The input file can be very large so we create an index that allowd us to access it in aggby-variables order without having to do a huge sort. --; proc datasets nolist library=&templib; modify aggin&UPtype; *--generate simple or compound index depending on whether we have 2+ aggby variables--; %if %scan(&aggby,2)= %str() %then %do; %*--Just 1 aggby var so a simple index--; index create &aggby; %end; %else %do; index create aggby=(&aggby); %end; quit; %end; %*---"pre" step processing do group-----------------; %if %index(&steps,agg) %then %do; *--We treat Median Value of Owner occ mobile homes (H82i1) as a mean because there is no distribution table for it.-; *--We treat the entire array of medians in PCT42 as means - no distributions.-; %agg(aggin=aggin&type,aggout=aggout&type, aggby=&aggby, %if &type=ph %then %do; aggvars=pop100 hu100 IntPtLat IntPtLon LandSQMI AreaSQMI P1i1 -- H121i7, means=IntPtLat IntPtLon P4i1 P82i1 P157ai1 p157bi1 p157ci1 p157di1 p157ei1 p157fi1 p157gi1 p157hi1 p157Ii1 H4i1 H4i2 H18i1-H18i3 H82i1, mweights=Landsqmi Landsqmi P3i1 P1i1 P6i2-P6i8 P7i10 P7i3 H3i2 H3i3 H7i1-H7i3 H32i11, /* *<===8-31-02=== */ %end; %else %if &type=phct %then %do; aggvars=Pct1i1 -- Hct28i13, means=Pct42i1-Pct42i15, mweights=Pct2i1-Pct2i15 , %end; %else %if &type=phctr %then %do; aggvars=pct62Ai1--hct48Ii3, means=, mweights=, %end; debug=1, idvars=&idvs, facvar=&afact, agglvl=&agglvl) run; %*<===8-31-02 changed name of parm from afact to facvar; %end; %*-------"agg" step processing------------------------------; %if %index(&steps,post) %then %do; *<---------------------Post-agg step---------------------------------; data &setoutlib..&setout.&type(compress=&compress); length &idlens; set aggout&type; %postexit %*<====================================================; %if &type=ph %then %do; *---Big thing to do here is to replace the medians with values that we estimate from the corresponding distribution tables usoing the median macro. It requires as parms 2 arrays: 1 with values representing the widths of the distribution array cells, and one with the frequency of occurrence of each interval.--; array _p52w{16} _temporary_ (10000 8*5000 10000 15000 3*25000 50000 100000); array _p52t{16} p52i2-p52i17; %median(mdn=P53i1,intvals=_p52t,intsize=_p52w,samestep=0); array _p55mtrx{7,0:16} P55i2-P55i120; *--a 2-dim matrix where we skip the first cell which is the total. We use the 0 subscripts at 2nd dimension to hold those subtotals, which we never reference-; array _p55t {16} _temporary_; %*--Do the medians for table 56 where we repeat the calculation for 7 different age categories--; P56i1=P53i1; *--same thing--; do _age=1 to 7; do _i_ = 1 to 16; _p55t{_i_}=_p55mtrx{_age,_i_}; end; array p56(*) p56i2-p56i8; %median(mdn=_p56mdn,intvals=_p55t,intsize=_p52w,samestep=1) ; p56(_age)=_p56mdn; drop _p56mdn; end; array _p76t{16} P76i2-P76i17; %median(mdn=P77i1,intvals=_p76t,intsize=_p52w,samestep=1) ; array _p79t{16} P79i2-P79i17; %median(mdn=P80i1,intvals=_p79t,intsize=_p52w,samestep=1) ; array _p84w{20} _temporary_ ( 10*2500 6*5000, 2*10000 25000 50000); array p84{2,20} p84i3-p84i22 p84i24-p84i43; array _p84t{20} _temporary_; do i=1 to 20; _p84t(i)=p84(1,i) + p84(2,i); *--add male and female to get total-; end; %median(mdn=P85i1,intvals=_p84t,intsize=_p84w,samestep=1); *--males--; do i=1 to 20; _p84t(i)=p84(1,i); end; %median(mdn=P85i2,intvals=_p84t,intsize=_p84w,samestep=1); *--females--; do i=1 to 20; _p84t(i)=p84(2,i); end; %median(mdn=P85i3,intvals=_p84t,intsize=_p84w,samestep=1); %let racecods=%upcase(abcdefghi); *--Assign the vars P152A thru P152I by accessing hh income distribution in corr P151 tables--; %do irace=1 %to 9; %let r=%substr(&racecods,&irace,1); *----Estimate P152&r.i1----; array _p151&r {16} p151&r.i2 - p151&r.i17; %median(mdn=P152&r.i1, intvals=_p151&r, intsize=_p52w, samestep=1); %end; *--Assign the vars P155A thru P155I by accessing family income distribution in corr P154 tables--; %do irace=1 %to 9; %let r=%substr(&racecods,&irace,1); array _p154&r {16} p154&r.i2 - p154&r.i17; %median(mdn=P155&r.i1, intvals=_p154&r, intsize=_p52w, samestep=1); %end; *--Assign the vars P156A thru P156I by accessing data in P151 (total households inc) and P154 (family hh inc). We have to calculate the differences to get the distr. of non-family household income counts.-; array _nfhhinc {16} _temporary_; %do irace=1 %to 9; %let r=%substr(&racecods,&irace,1); do i=1 to 16; _nfhhinc{i}= _p151&r{i} - _p154&r{i}; end; %median(mdn=P156&r.i1, intvals=_nfhhinc, intsize=_p52w,samestep=1); %end; array _h23w {9} _temporary_ (8*1 2); array _h23t {9} h23i2-h23i10; %median(mdn=H24i1,intvals=_h23t,intsize=_h23w,samestep=1); h24i1=h24i1 + .5; *<--adjust upward half a room-; array _h26Owner{9} h26i3-h26i11; array _h26Renter{9} h26i13-h26i21; array _h26TotOcc{9} _temporary_; do i=1 to 9; _h26TotOcc(i)=_h26Owner(i) + _h26Renter(i); end; %median(mdn=H27i1,intvals=_h26TotOcc,intsize=_h23w,samestep=1); %median(mdn=H27i2,intvals=_h26Owner,intsize=_h23w,samestep=1); %median(mdn=H27i3,intvals=_h26renter,intsize=_h23w,samestep=1); h27i1=h27i1+.5; h27i2=h27i2+.5; h27i3=h27i3+.5; array _h34w {9} _temporary_ (1.25 4 5 5*10 25); array _h34t{9} h34i2-h34i10; %median(mdn=_mednage,intvals=_h34t, intsize=_h34w,samestep=1); *--To get median year built we calculate age and subtract--; h35i1= round( 2000.25 - _mednage ); drop _mednage; h37i1=h35i1; array _h36owner{9} h36i3-h36i11; %median(mdn=_mednage, intvals=_h36owner, intsize=_h34w,samestep=1); H37i2= round( 2000.25 - _mednage); array _h36renter{9} h36i13-h36i21; %median(mdn=_mednage, intvals=_h36renter, intsize=_h34w,samestep=1); H37i3= round( 2000.25 - _mednage); array _h38w {6} _temporary_ (1.25 4 5 10 10 20); array _h38owner {6} h38i3-h38i8; array _h38renter{6} h38i10-h38i15; array _h38total{6} _temporary_; %median(mdn=_yearsin,intvals=_h38owner,intsize=_h38w,samestep=1); if h38i2 then H39i2 = round( 2000.25 - _yearsin); else h39i2=.; *<===8-31-02===; %median(mdn=_yearsin,intvals=_h38renter,intsize=_h38w,samestep=1); if h38i9 then H39i3 = round( 2000.25 - _yearsin); else h39i3=.; *<===8-31-02===; if h38i1 then if h38i2=0 then H39i1=H39i3; else if h38i9=0 then H39i1=H39i2; else do; do i=1 to 6; _h38total{i}= _h38renter{i} + _h38owner{i}; end; %median(mdn=_yearsin,intvals=_H38total,intsize=_h38w,samestep=1); H39i1= round( 2000.25 - _yearsin); drop _yearsin; end; array _h54w{21} _temporary_ (100 50 50 50 50 50 50 50 50 50 50 50 50 50 50 100 100 250 250 500 1000); array _h54t{21} H54i3-H54i23; %median(Q1=H55i1, intvals=_h54t, intsize=_h54w,samestep=1); %median(mdn=H56i1, intvals=_h54t, intsize=_h54w,samestep=1); %median(Q3=H57i1, intvals=_h54t, intsize=_h54w,samestep=1); array _h59t{21} h59i2-h59i22; if h59i1 = 0 then h60i1=.; else do; %median(mdn=H60i1,intvals=_h59t,intsize=_h54w,samestep=1); end; array _h62t {21} h62i3-h62i23; if h62i2=0 then H63i1=.; else do; %median(mdn=H63i1,intvals=_h62t,intsize=_h54w,samestep=1); end; array _h69t{9} h69i2-h69i10; array _h69w{9} _temporary_ (10 6*5 10 15); %median(mdn=H70i1,intvals=_h69t,intsize=_h69w,samestep=1); array _h74w{24} _temporary_ (10000 6*5000 6*10000 4*25000 2*50000 2*100000 2*250000 500000); array _h74t{24} h74i2-h74i25; %median(Q1=H75i1, intvals=_h74t, intsize=_h74w,samestep=1); %median(mdn=H76i1, intvals=_h74t, intsize=_h74w,samestep=1); %median(Q3=H77i1, intvals=_h74t, intsize=_h74w,samestep=1); array _h84t{24} h84i2-h84i25; %median(mdn=H85i1, intvals=_h84t, intsize=_h74w,samestep=1); array _h87t{24} h87i2-h87i25; %median(mdn=H88i1,intvals=_h87t,intsize=_h74w,samestep=1); array _h90wMort{15} _temporary_ (200 8*100 2*250 3*500 1000); array _h90wNoMort{14} _temporary_ (100 6*50 6*100 200); array _h90tMort{15} h90i3-h90i17; array _h90tNoMort{14} h90i19-h90i32; %median(mdn=H91i1,intvals=_h90tMort,intsize=_h90wMort,samestep=1); %median(mdn=H91i2,intvals=_h90tNoMort,intsize=_h90wNoMort,samestep=1); array _h94tMort{9} h94i3-h94i11; array _h94tNoMort{9} h94i14-h94i22; array _h94tTotal{9} _temporary_; do i=1 to 9; _h94tTotal(i)=_h94tMort(i) + _h94tNoMort(i); end; %median(mdn=H95i1,intvals=_h94tTotal,intsize=_h69w,samestep=1); %median(mdn=H95i2,intvals=_h94tMort,intsize=_h69w,samestep=1); %median(mdn=H95i3,intvals=_h94tNoMort,intsize=_h69w,samestep=1); *----Round off the medians, weighted averages, etc.-----------------------*; array _onedec P4i1 H4i1 H4i2 h24i1 h27i1-h27i3 h70i1 H95i1-H95i3; do i=1 to dim(_onedec); _onedec{i}=round(_onedec{i}, .1); end; h18i1=round(h18i1,.01); h18i2=round(h18i2,.01); h18i3=round(h18i3,.01); format h18i1-h18i3 5.2; array _othersph P82i1 P157ai1 p157bi1 p157ci1 p157di1 p157ei1 p157fi1 p157gi1 p157hi1 p157Ii1 p53i1 p56i1-p56i8 p77i1 p80i1 p85i1-p85i3 p152ai1--p152Ii1 p155Ai1--p155Ii1 p156Ai1--p156Ii1 h35i1 h37i1-h37i3 h39i1-h39i3 h55i1 h56i1 h57i1 h60i1 h63i1 h75i1 h76i1 h77i1 h85i1 h88i1 h91i1 h91i2 ; do i=1 to dim(_othersph); _othersph{i}=round(_othersph{i}); end; %end; %*---end ph processing------------------------------------; %else %if &type=phct %then %do; %*--------Begin phct processing-------------------------------; array _pct38w{16} _temporary_ (10000 8*5000 10000 15000 3*25000 50000 100000); array _pct38mtx{6,16} pct38i4-pct38i19 pct38i21-pct38i36 pct38i40-pct38i55 pct38i57-pct38i72 pct38i75-pct38i90 pct38i92-pct38i107; array _pct38TOTFAMt(16) _temporary_; array _pct38NOKIDSt(16) _temporary_; array _pct38KIDSt(16) _temporary_; do i=1 to 16; %*--aggregate to get the tally arrays for the 3 medians in pct39--; _pct38KIDSt(i)= _pct38mtx(1,i) + _pct38mtx(3,i) + _pct38mtx(5,i); _pct38NOKIDSt(i)= _pct38mtx(2,i) + _pct38mtx(4,i) + _pct38mtx(6,i); _pct38TOTFAMt(i)= _pct38KIDSt(i) + _pct38NOKIDSt(i); end; %median(mdn=pct39i1,intvals=_pct38TOTFAMt,intsize=_pct38w,samestep=0); %median(mdn=pct39i2,intvals=_pct38KIDSt,intsize=_pct38w,samestep=1); %median(mdn=pct39i3,intvals=_pct38NOKIDSt,intsize=_pct38w,samestep=1); array _pct38MCt(16) _temporary_; array _pct38MCKIDSt(16) pct38i4-pct38i19; array _pct38MCNOKIDSt(16) pct38i21-pct38i36; array _pct38OFAMt(16) _temporary_; *--Other family-; array _pct38MHHNWt(16) _temporary_; array _pct38MHHNWKIDSt(16) pct38i40-pct38i55; *--Male HouseHolder No Wife with KIDS-; array _pct38MHHNWNOKIDSt(16) pct38i57-pct38i72; array _pct38FHHNHt(16) _temporary_; array _pct38FHHNHKIDSt(16) pct38i75 -pct38i90; *--Female HouseHolder No Husband with KIDS-; array _pct38FHHNHNOKIDSt(16) pct38i92 - pct38i107; do i=1 to 16; _pct38MCt(i)=_pct38MCKIDSt(i) + _pct38MCNOKIDSt(i); _pct38OFAMt(i)= _pct38TOTFAMt(i) - _pct38MCt(i); _pct38MHHNWt(i)= _pct38MHHNWKIDSt(i) + _pct38MHHNWNOKIDSt(i); _pct38FHHNHt(i)= _pct38FHHNHKIDSt(i) + _pct38FHHNHNOKIDSt(i); end; pct40i1=pct39i1; %median(mdn=pct40i2,intvals=_pct38MCt,intsize=_pct38w,samestep=1); %median(mdn=pct40i3,intvals=_pct38MCKIDSt,intsize=_pct38w,samestep=1); %median(mdn=pct40i4,intvals=_pct38MCNOKIDSt,intsize=_pct38w,samestep=1); %median(mdn=pct40i5,intvals=_pct38OFAMt,intsize=_pct38w,samestep=1); %median(mdn=pct40i6,intvals=_pct38MHHNWt,intsize=_pct38w,samestep=1); %median(mdn=pct40i7,intvals=_pct38MHHNWKIDSt,intsize=_pct38w,samestep=1); %median(mdn=pct40i8,intvals=_pct38MHHNWNOKIDSt,intsize=_pct38w,samestep=1); %median(mdn=pct40i9,intvals=_pct38FHHNHt,intsize=_pct38w,samestep=1); %median(mdn=pct40i10,intvals=_pct38FHHNHKIDSt,intsize=_pct38w,samestep=1); %median(mdn=pct40i11,intvals=_pct38FHHNHNOKIDSt,intsize=_pct38w,samestep=1); array _pct44w(20) _temporary_ (2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 5000, 5000, 5000, 5000, 5000, 5000, 10000, 10000, 25000, 50000); array _pct44MFT(20) pct44i6-pct44i25; array _pct44MNFT(20) pct44i29-pct44i48 ; *--Male NOT full-time year-round--; array _pct44FFT(20) pct44i53-pct44i72; array _pct44FNFT(20) pct44i76-pct44i95; array _pct44MTOT(20) _temporary_; array _pct44FTOT(20) _temporary_; do i=1 to 20; _pct44MTOT(i)=_pct44MFT(i) + _pct44MNFT(i); _pct44FTOT(i)=_pct44FFT(i) + _pct44FNFT(i); end; %median(mdn=pct45i1,intvals=_pct44MTOT,intsize=_pct44w,samestep=0); %median(mdn=pct45i2,intvals=_pct44MFT,intsize=_pct44w,samestep=0); %median(mdn=pct45i3,intvals=_pct44MNFT,intsize=_pct44w,samestep=0); %median(mdn=pct45i4,intvals=_pct44FTOT,intsize=_pct44w,samestep=0); %median(mdn=pct45i5,intvals=_pct44FFT,intsize=_pct44w,samestep=0); %median(mdn=pct45i6,intvals=_pct44FNFT,intsize=_pct44w,samestep=0); array _pct46w(20) _temporary_ (10*2500 6*5000 2*10000 25000 50000); array _pct46MFT(20) pct46i6-pct46i25; array _pct46MNFT(20) pct46i29-pct46i48; *--Male NOT full-time year-round--; array _pct46FFT(20) pct46i53-pct46i72; array _pct46FNFT(20) pct46i76-pct46i95; array _pct46MTOT(20) _temporary_; array _pct46FTOT(20) _temporary_; array _PCT46fttot(20) _temporary_; array _PCT46nfttot(20) _temporary_; do i=1 to 20; _pct46MTOT(i)=_pct46MFT(i) + _pct46MNFT(i); _pct46FTOT(i)=_pct46FFT(i) + _pct46FNFT(i); _pct46fttot(i)=_pct46MFT(i) + _pct46FFT(i); _pct46nfttot(i)=_pct46MNFT(i) + _pct46FNFT(i); end; %median(mdn=pct47i1,intvals=_pct46fttot,intsize=_pct46w,samestep=0); %median(mdn=pct47i2,intvals=_pct46MFT,intsize=_pct46w,samestep=0); %median(mdn=pct47i3,intvals=_pct46FFT,intsize=_pct46w,samestep=0); %median(mdn=pct47i4,intvals=_pct46nfttot,intsize=_pct46w,samestep=0); %median(mdn=pct47i5,intvals=_pct46MNFT,intsize=_pct46w,samestep=0); %median(mdn=pct47i6,intvals=_pct46FNFT,intsize=_pct46w,samestep=0); array _hct11Owner(11) hct11i3-hct11i13 ; array _hct11Renter(11) hct11i15-hct11i25; array _hct11Total(11) _temporary_; array _hct11w(11) _temporary_ ( 5*5000 10000 15000 2*25000 50000 100000); do i=1 to 11; _hct11Total(i)=_hct11Owner(i) + _hct11Renter(i); end; %median(mdn=hct12i1,intvals=_hct11total,intsize=_hct11w,samestep=1); %median(mdn=hct12i2,intvals=_hct11owner,intsize=_hct11w,samestep=1); %median(mdn=hct12i3,intvals=_hct11renter,intsize=_hct11w,samestep=1); array _hct19(15) hct19i16 hct19i2-hct19i15; *<====the zero taxes is at the top! We put it back at bottom; array _hct19w(15) _temporary_ (0 200 2*100 3*200 2*500 3*1000 2*2500 3500); %median(mdn=hct20i1,intvals=_hct19,intsize=_hct19w,samestep=1); *----Round off the medians and weighted averages-----------------------*; array _othersphct pct39i1-pct39i3 pct40i1-pct40i11 pct45i1-pct45i6 pct47i1-pct47i6 hct12i1-hct12i3 hct20i1 ; do i=1 to dim(_othersphct); _othersphct{i}=round(_othersphct{i}); end; %end; %*---of phct file processing-----------------------------------------------; %else %if &type=phctr %then %do; array _pct73w (20) _temporary_ (10*2500 6*5000 2*10000 25000 50000); %*--we have a series of distribution arrays for the 9 race categories, followed by a set of 9 medians associated with those arrays in the pct74 tables. Time to loop. --; %let racecods=%upcase(abcdefghi); %do irace=1 %to 9; %let r=%substr(&racecods,&irace,1); array _pct73&r.MFT(20) pct73&r.i6-pct73&r.i25; array _pct73&r.MNFT(20) pct73&r.i29-pct73&r.i48; *--Male NOT full-time year-round--; array _pct73&r.FFT(20) pct73&r.i53-pct73&r.i72; array _pct73&r.FNFT(20) pct73&r.i76-pct73&r.i95; array _pct73&r.FTTOT(20) _temporary_; array _pct73&r.NFTTOT(20) _temporary_; do i=1 to 20; _pct73&r.FTTOT(i)=_pct73&r.MFT(i) + _pct73&r.FFT(i); _pct73&r.NFTTOT(i)=_pct73&r.MNFT(i) + _pct73&r.FNFT(i); end; %median(mdn=pct74&r.i1,intvals=_pct73&r.FTTOT,intsize=_pct73w,samestep=1); %median(mdn=pct74&r.i2,intvals=_pct73&r.MFT,intsize=_pct73w,samestep=1); %median(mdn=pct74&r.i3,intvals=_pct73&r.FFT,intsize=_pct73w,samestep=1); %median(mdn=pct74&r.i4,intvals=_pct73&r.NFTTOT,intsize=_pct73w,samestep=1); %median(mdn=pct74&r.i5,intvals=_pct73&r.MNFT,intsize=_pct73w,samestep=1); %median(mdn=pct74&r.i6,intvals=_pct73&r.FNFT,intsize=_pct73w,samestep=1); %end; array _hct36w(21) _temporary_ (100 14*50 2*100 2*250 500 750); %do irace=1 %to 9; %let r=%substr(&racecods,&irace,1); array _hct36&r(21) hct36&r.i3-hct36&r.i23; %median(mdn=hct37&r.i1,intvals=_hct36&r,intsize=_hct36w,samestep=1); %end; array _hct39w(9) _temporary_ (10 6*5 10 15); %do irace=1 %to 9; %let r=%substr(&racecods,&irace,1); array _hct39&r(9) hct39&r.i2-hct39&r.i10; %median(mdn=hct40&r.i1,intvals=_hct39&r,intsize=_hct39w,samestep=1); %end; array _hct41w(24) _temporary_ (10000 6*5000 6*10000 4*25000 2*50000 2*100000 2*250000 500000); %do irace=1 %to 9; %let r=%substr(&racecods,&irace,1); array _hct41&r(24) hct41&r.i2-hct41&r.i25; %median(mdn=hct42&r.i1,intvals=_hct41&r,intsize=_hct41w,samestep=1); %end; array _hct44Mortw(15) _temporary_ (200 8*100 2*250 3*500 750); array _hct44NoMortw(14) _temporary_ (100 6*50 6*100 1100); %do irace=1 %to 9; %let r=%substr(&racecods,&irace,1); array _hct44&r.Mort(15) hct44&r.i3-hct44&r.i17; array _hct44&r.NoMort(14) hct44&r.i19-hct44&r.i32; %median(mdn=hct45&r.i1,intvals=_hct44&r.Mort,intsize=_hct44Mortw,samestep=1); %median(mdn=hct45&r.i2,intvals=_hct44&r.NoMort,intsize=_hct44NoMortw,samestep=1); %end; array _hct47w(9) _temporary_ (10 6*5 10 15); array _hct47tot(9) _temporary_; %do irace=1 %to 9; %let r=%substr(&racecods,&irace,1); array _hct47&r.Mort(9) hct47&r.i3-hct47&r.i11; array _hct47&r.NoMort(9) hct47&r.i14-hct47&r.i22; do i=1 to 9; _hct47tot(i)=_hct47&r.Mort(i) + _hct47&r.NoMort(i); end; %median(mdn=hct48&r.i1,intvals=_hct47tot,intsize=_hct47w,samestep=1); %median(mdn=hct48&r.i2,intvals=_hct47&r.Mort,intsize=_hct47w,samestep=1); %median(mdn=hct48&r.i3,intvals=_hct47&r.NoMort,intsize=_hct47w,samestep=1); %end; array _onedecphct hct40Ai1 -- hct40Ii1 hct48Ai1 -- hct48Ii3 ; do i=1 to dim(_onedecphct); _onedecphct{i}=round(_onedecphct{i}, .1); end; array _othersphctr pct74ai1 -- pct74Ii6 hct37Ai1--hct37Ii1 hct42Ai1--hct42Ii1 hct45Ai1--hct45Ii2 ; do i=1 to dim(_othersphctr); _othersphctr{i}=round(_othersphctr{i}); end; %end; %*----phctr processing----------------------------------------------------; drop i; drop _lvl_ _nag_; drop _age; drop _haf -- _slot2 _q1 _q3; *--temp vars used by median macro--; run; %end; %*--"post" step processing---------------------; %if &report %then %do; %*---This step is only relevant if you create a state totals sum to use as a check--; %if &type=ph %then %let vars= pop100 p1i1 IntPtLat IntPtLon P4i1 P82i1 P157ai1 p157bi1 p157ci1 p157di1 p157ei1 p157fi1 p157gi1 p157hi1 p157Ii1 p53i1 p56i1-p56i8 p77i1 p80i1 p85i1-p85i3 p152ai1--p152Ii1 p155Ai1--p155Ii1 p156Ai1--p156Ii1 H4i1 H4i2 H18i1-H18i3 H24i1 h27i1-h27i3 h35i1 h37i1-h37i3 h39i1-h39i3 h55i1 h56i1 h57i1 h60i1 h63i1 h70i1 h75i1 h76i1 h77i1 h85i1 h88i1 h91i1 h91i2 H95i1-H95i3 ; %else %if &type=phct %then %let vars=pct39i1-pct39i3 pct40i1-pct40i11 pct45i1-pct45i6 pct47i1-pct47i6 hct12i1-hct12i3 hct20i1 ; %else %if &type=phctr %then %let vars= pct74Ai1 -- pct74Ii6 hct37Ai1--hct37Ii1 hct42Ai1--hct42Ii1 hct45Ai1--hct45Ii2 hct40Ai1 -- hct40Ii1 hct48Ai1 -- hct48Ii3 ; data origagg&type; set sf3.&setin&type(keep=sumlev geocomp &vars where=(sumlev='040' and geocomp='00') in=inorig) &setoutlib..&setout&type(keep=sumlev state &vars where=(sumlev='040')); if inorig then set='Original'; else set='Aggregat'; run; proc print data=origagg&type; id set; title3 "Comparison of Selected Variables in Original Set and Aggregated Estimates - Type &type"; run; %end; %*---report step processing----; %let itype=%eval(&itype+1); %let type=%scan(&settypes,&itype); %end; %*--do while type loop--; %mend aggsf3;