x cd /pub/data/pl9490/Tools; %let pgm=pl94trend_00geog_mo; filename pgm "&pgm..sas"; *---This setup will generate sas datasets in the pl9490tx subdirectory of pl9490. These sets are suitable for use as input to the pl94 trend reports that allow juxtaposing basic pl94 pop data for 1990 and 2000. The data sets generated here involve converting from 1990 census geography to 2000 geography using a 1990 to 2000 Missouri block correlation list as created in cnvt.bl90_bl2k.sas in corrlst/Tools. jgb, 3-9-01. ---*; *libname user '/tmp/storage/user8'; libname pl9490 '/pub/data/pl9490' access=readonly; libname pl9490tx '/pub/data/pl9490/pl9490tx'; libname corrlst '/pub/data/corrlst' access=readonly; *-----------All Missouri data in this setup-------------*; %macro concatd(g1,g2,g3,g4,g5,g6,g7); %*--utility macro to return a SAS expression that will be the concatenation of specified char variables separated by dashes-; %local dash gc; %let dash=%str(||'-'||); %*--we build the value of local variable gc which is then "returned" as the result of invoking the macro-; %let gc=&g1; %if &g2= %then %goto rtrn; %let gc=&gc&dash&g2; %if &g3= %then %goto rtrn; %let gc=&gc&dash&g3; %if &g4= %then %goto rtrn; %let gc=&gc&dash&g4; %if &g5= %then %goto rtrn; %let gc=&gc&dash&g5; %if &g6= %then %goto rtrn; %let gc=&gc&dash&g6; %if &g7= %then %goto rtrn; %let gc=&gc&dash&g7; %rtrn: &gc %mend concatd; *===========Allocate 1990 pl94 data to 2000 census blocks================*; /*<=========================Comment out===================================== ===========================End commented out================================ */ *--the blocks data for MO is in 3 subsets which we concatenate (interleave actually) using a data step view here---; data mo90blks/view=mo90blks; set pl9490.moxxblks pl9490.mokcblks pl9490.moslblks; by county tract blk; run; *--create data to be aggregated by joining the 90 pl data with the blk correlation list-; data aggin(drop=p1i1 pop90a notin) nomatch(keep=county tract90 block90 pop90a p1i1 h1i1 notin); *--match the pl94 90 blocks with the corr list to attach the 2000 geocodes, i.e. tract and block; length notin $7 ; merge mo90blks(in=inpl94 rename=(tract=tract90 blk=block90) keep=county tract blk _numeric_) corrlst.mobl902k(in=inclist where=(substr(block90,2,2) ne '99')); by county tract90 block90; *****************if county gt '29003' then stop; **********TESTING*********************; if not (inclist and inpl94) then do; if inclist then notin='PL94 '; else notin='CORRLST'; output nomatch; return; end; *--borrow code from that used to create the 2k pl94 data sets--; length default=5; *block=blk; format tract ; *---somewhere this var had a format of $6. assigned when it should be $7, if anything; length bg $1; bg=block; *--2000 block group--; *--assign all the vars to corresponding names used in the pl94-2000 mosums data set(s)--; totpop=p1i1; tothus=h1i1; *<-----keep the total households even if it is not in the trend reports because not on 2000; white1=p2i1; black1=p2i2; indian1=p2i3; asianpi=p2i4; *--NOT the same as a 1990 category-; other1=p2i5; whovr181=p3i1; blovr181=p3i2; inovr181=p3i3; aspovr18=p3i4; otovr181=p3i5; over18=sum(of p3i1-p3i5); hisppop=p4i1; whitenh1=p4i2; hisovr18=p5i1; wnovr181=p5i2; output aggin; label totpop='1990 complete count pop'; label tract='tract 2000' block='block 2000'; keep notin pop90a p1i1 h1i1 county tract90 block90 tract bg block afact totpop -- wnovr181 ; *--only keep mostly the new variable (names)--; run; proc sort data=aggin; by county tract block afact; run; *--sort by the newly attached 2000 geocodes-; %agg(aggin=aggin,aggout=aggout,aggby=county tract bg block,agglvls=4,grand=1,aggvars=totpop--wnovr181,facvar=afact) ; data pl9490tx.moblks00(label='1990 pl94 extract by 2000 census blks') pl9490tx.mobgs00(label='1990 pl94 extract by 2000 census block grps' drop=block afact nagg) pl9490tx.motrs00(label='1990 pl94 extract by 2000 census tracts' drop=bg block afact nagg) pl9490tx.mocntyck(label='1990 pl94 extract check sums: st and cnty' drop=tract bg block afact nagg); length sumlev $3 county $5 tract $7 bg$1 block $5 geocode $32 areaname $16; set aggout; array counts(*) totpop--wnovr181; do _i_=1 to dim(counts); counts(_i_)=round(counts(_i_),.1); *--round all counts to 1 decimal place--; end; drop _i_; select (_lvl_); when(1) do; sumlev='100'; *--not really 750 becuase we are not carrying along the vtd code--; geocode=%concatd(county,tract,block); areaname='Block '||block; output pl9490tx.moblks00; end; when(2) do; sumlev='150'; *--not really 7xx becuase we are not carrying along the vtd code--; geocode=%concatd(county,tract,bg); areaname='Block Grp '||bg; output pl9490tx.mobgs00; end; when(3) do; sumlev='140'; *--not really 7xx becuase we are not carrying along the vtd code--; geocode=%concatd(county,tract); areaname='Tract '||tract; output pl9490tx.motrs00; end; when(4) do; sumlev='050'; geocode=county; areaname=put(county,$county.); output pl9490tx.mocntyck; end; when(99) do; sumlev='040'; geocode='29'; areaname='Missouri'; output pl9490tx.mocntyck; end; otherwise do; put /'***Unexpected value for _lvl_ code: ' _lvl_= / _all_; delete; end; end; *--select--; rename _nag_=nagg; label _nag_='# of block or blk parts aggregated' afact='Largest allocation factor' sumlev='Geo Summary Level' tothus='Total Housing Units'; drop _lvl_; run; proc sort data=pl9090tx.mocntyck; by slvl county; run;