x cd /pub/data/popests/Tools; %let pgm=cnvt_usnchsbridged200x_intrcnsl; filename pgm "&pgm..sas"; *---This setup being used to convert the 2000-2009 intercensal estimates as released by NCHS Oct. 26, 2012. These new datasets will basically supercede the old 20xx datasets based on 2000-census post-censal estimates. jgb, begin coding 10/2012. --; *-NOTE: This job creates the input which is used by setup nchsbridged_sumry.sas to (re)create the nchsbridged200x_summary data sets which are used by the estimates_by_age web app. Also used for data in the poptrends web application. Check for details. ---*; title "&pgm : Convert Custom Intercensal Pop Estimates from NCHS with 'Bridged' Race Cats by Single Yrs"; libname popests '/pub/data/popests'; libname nchsbri '/pub/data/popests/nchsbri'; filename indata1 pipe "unzip -p ../rawdata/icen_2000_09_y0004.zip icen_2000_09_y0004.txt"; filename indata2 pipe "unzip -p ../rawdata/icen_2000_09_y0509.zip icen_2000_09_y0509.txt"; %let dataset=nchsbri.usnchsbridged200x_intrcnsl; %macro dofile(flno); data file&flno; %if &flno=1 %then %do; %let yr1=00; %let yr2=04; %end; %else %do; %let yr1=05; %let yr2=09; %end; infile indata&flno stopover termstr=crlf; length State $2 County $5 Age $2 Race $1 Sex Hispanic $1 PopJl&yr1 - PopJl&yr2 5; input _series $8. State $2. _co3 $3. Age $char2. _racesex 1. Hispanic $1. (PopJL&yr1 - PopJL&yr2) (8.); if _series ne "i2000_09" then abort abend; County=State||_co3; if substr(age,1,1)=' ' then substr(age,1,1)='0'; if _racesex in ( 1, 3, 5, 7) then Sex='1'; else Sex='2'; if _racesex le 2 then Race='1'; else if _racesex le 4 then race='2'; else if _racesex le 6 then race='3'; else race='4'; *---Code values here are: Race: 1=white 2=black 3=American Ind etc 4=Asian PI. Sex: 1=male 2=female Hispanic: 1=non 2=hispanic. Age: 0= under 1 yr 1=1 yeuar old ... 85=85 and over. ---*; label %do iyr=&yr1 %to &yr2; popjl0&iyr="Pop Estimate July, 200&iyr" %end; ; drop _:; run; %mend dofile; options mprint; %dofile(1) ; options nomprint; %dofile(2); data &dataset (label="Intercensal Pop Ests from NCHS by Single Yrs of Age, Bridged Race, Sex and Hispanic, 2000-2009" sortedby=state county index=(state)); length State stab $2; merge file1 (in=in1) file2 (in=in2 rename=(county=_countyck hispanic=_hispanicck)); ****NO By statement. The files do appear to be in complete synch but we do have a check here ******; if county ne _countyck or hispanic ne _hispanicck then do; put / "Files are out of synch: county and hispanic not matching" / _all_; abort abend; end; stab=put(state,$fipstab.); if not (in1 and in2) then do; put /'Files not in synch: ' _all_; abort abend; end; drop _: ; run; proc print data=&dataset(obs=50); by state; id county; title2 "Intercensal Estimates from nchs Oct 2012"; run; proc means data=&dataset(where=(state in ('17','29')) sum; var popjl00--popjl09; run;