x cd /pub/data/sf12000x/Tools; %let pgm=cnvt_us; filename pgm "&pgm..sas"; *----Create sf12000x.us (advanced national file) & sf1x.us_geocomps (non-00 geocomp summaries) from sf12000 and stf901x2 sets. J. Blodgett, 12-4-01. ----*; libname sf12000 '/pub/data/census_2000/sf12000' access=readonly; libname sf1 (sf12000); *--alternate libref--; libname sf12000x '/pub/data/sf12000x'; libname sf1x (sf12000x); *--alternate libref--; %libname(stf901x2); *<---custom generated 1990 stf1 extract set ready to be merged with our sf2000x data set-; %libname(stf903x); signon oseda; *--to reference the gics90 data sets--; libname gics90 remote '/mscdc/data/georef/gics90' server=oseda; libname user '/SAS_temp/user'; %let stab=us; ***stf901x2.&stab ( &keep90 in=in90); *---Retrieve the 1990 pop counts from various sources for various levels. We get data for: -places and county subdivsions from gics90 -zip codes from stf903x (only sample pop available -- pretty shaky) -all other (state,county,msacmsa, from stf901/stf901x2 pmsa) ---------*; /*<=========================Comment out===================================== data pop90gics; set gics90.places gics90.cousubs; SumLev=gicsrt; length SumLev $3 geocode $40 county $5; keep sumlev geocode pop90; SumLev=gicsrt; select(sumlev); when ('060') geocode=%concatd(state,cousubfp); when ('155') do; county=state||cnty; geocode=%concatd(county,placefp); end; when ('160') geocode=%concatd(state,placefp); otherwise delete; end; pop90=pop100; run; proc sort; by sumlev geocode; run; data pop90stf3x; set stf903x.uszips; length SumLev $3 geocode $5; keep sumlev geocode pop90; sumlev='860'; *<---obviously a stretch but we will have some valid instances--; geocode=zip; pop90=totpop; run; proc sort; by geocode; run; ===========================End commented out================================ */ data pop90s; set stf901x2.us(in=in1x keep=SumLev Geocode totpop rename=(totpop=pop90)) pop90gics(in=ingics) pop90stf3x(in=in3x); by sumlev geocode; if last.geocode; *<---we have duplicates between gics and 901x2--; length source $2; if in1x then source='1x'; else if ingics then source='gi'; else source='3x'; run; data _&stab ; *---Merge the full sf12000 sets to get the census 2000 data set, ready to be merged with the 90 pops; length default=5; length esriid $42.; merge sf1.&stab.geos (in=ingeos) sf1.&stab.phng sf1.&stab.pctng end=last; by geo_id; format county $county.; %include sascode(sf12000x); *--gets code in /pub/sascode/sf12000x.sas---; *--keep list here is for ids only. Variables totpop -- year are kept as part of included code--; keep sumlev geo_id geocode geocomp state stab areaname county msacmsa pmsa cd106 Region Division aianhhfp cousubfp placefp zcta5 areasqmi landsqmi intptlon intptlat esriid; run; proc sort data =_&stab; by sumlev geocode; run; options msglevel=i; data sf1x.&stab(index=(sumlev) compress=yes) sf1x.us_geocomps; *<<<**********; merge _&stab(in=in2k) pop90s (in=in90); ***stf901x2.&stab ( &keep90 in=in90); by sumlev geocode; if in2k; if not in90 then totpop90=.; else totpop90=pop90; drop pop90; if totpop90 ne . then do; change=totpop - totpop90; if totpop90 then pctchange=100*change/totpop90; end; if geocomp='00' then output sf1x.us; else output sf1x.us_geocomps; *<<<**********; run; *<======US convert only**************************; proc datasets library=sf12000x nolist; modify us; index create state; quit; proc format; value pop .='NA' other='Yes'; run; options linesize=100 ; proc freq data=sf12000x.&stab; table sumlev * totpop90/missing; *format sumlev $sumlev. totpop90 pop.; format sumlev $3. totpop90 pop.; title2 'Freq Report Showing Summary Levels and Whether We Have a 1990 Pop Count for It'; run; proc contents data=sf12000x.&stab position; title2 "stf901x2.&stab Contents Report"; run;