x cd /pub/data/sf12000x/Tools; %let pgm=molibdists; filename pgm "&pgm..sas"; *----Specific occurrence of general convert routine. Run just for Missouri Library Districts, both complete and within-county. John Blodgett, OSEDA, Coded Jan. 14, 2003. ----*; title 'Convert Mo Library District SF1 Data to SF1X Extract'; libname sf12000 '/pub/data/census_2000/sf12000' access=readonly; libname corrlst '/pub/data/corrlst' access=readonly; libname sf12000x '/pub/data/sf12000x'; libname user '/tmp/storage/john'; *<==================; title "&pgm from sf12000/Tools: Create sf1x.molibdists and molibdistcos"; *----Aggregate the correlation list to get 1990 pops by district, complete and within-county--; proc means noprint data=corrlst.mobl2libd; class distcode county; var totpop90; types distcode distcode*county; output out=popsums90 sum=totpop90; run; proc print data=popsums90(obs=50); title2 "popsums90"; run; *---------------Part 1: Complete Districts------------------------------------*; data _2000s; length default=5; length esriid $3; merge sf1.molibdistsph sf1.molibdistspct; by geocode; %include sascode(sf12000x.sas); keep sumlev geocode distcode areaname areasqmi intptlon intptlat esriid; *--in addtion to totpop etc.--; run; proc sort data=_2000s; by distcode ; run; data sf1x.molibdists(label='Mo Library Districts'); merge _2000s (in=in2k) popsums90(in=in90 keep= distcode _type_ totpop90 where=(_type_=2)); by distcode; if in2k; change=totpop - totpop90; if totpop90 then pctchange=100*change/totpop90; drop _type_; run; proc print data=sf1x.molibdists(obs=50); var _char_ totpop totpop90 change pctchange; title2 'Selected Vars from sf1x.molibdists'; run; *--------------------Part 2: Districts Within Counties-------------------------------*; data _2000s2; length default=5; length esriid $9; merge sf1.molibdistcosph sf1.molibdistcospct; by geocode; %include sascode(sf12000x.sas); keep sumlev geocode distcode areaname county partflag areasqmi intptlon intptlat esriid; *--in addtion to totpop etc.--; run; proc sort data=_2000s2; by distcode county; run; data sf1x.molibdistcos(label='Mo Library Districts within Counties'); merge _2000s2 (in=in2k) popsums90(in=in90 keep= distcode county _type_ totpop90 where=(_type_=3)); by distcode county; if not in90 then do; _no90+1; if _no90 <= 50 then do; put distcode= county= ; delete; end; else stop; end; drop _type_; if in2k; change=totpop - totpop90; if totpop90 then pctchange=100*change/totpop90; run; proc print data=sf1x.molibdistcos(obs=50); var _char_ totpop totpop90 change pctchange; title2 'Selected Vars from sf1x.molibdistcos'; run;