x cd /pub/data/popests/Tools; %let pgm=cnvt_nchs_bridged90s; filename pgm "&pgm..sas"; *---Read the custom single-year-of-age by "bridged" race by sex and hispanic intercensal (1990-1999) estimates downloaded from NCHS web site and created for them by the Census Bureau. Create datasets nchsbri.monchsbridged19xx . John Blodgett, OSEDA under contract with Missouri Census Data Center. Coded 12-19-05. ---*; title "&pgm : Convert Custom Pop Estimates from NCHS with 'Bridged' Race Cats by Single Yrs for the 1990s"; libname nchsbri '/pub/data/popests/nchsbri'; **filename saveraw '/pub/data/popests/sample_nchsbridged90s.txt'; %macro doit(state,stab,compress=no); %*let dataset=popests.monchsbridged19xx; %let dataset=nchsbri.&stab.nchsbridged19xx; *<===============================================================; %let ustab=%upcase(&stab); %*--there are 4 zip files, each with an interval of states and with a single digit in the name. Here we assign the value of that digit to the varialbe zipfile which we shall then reference in the following filename stmt--; %if &state le 18 %then %let zipfile=1; %else %if &state le 29 %then %let zipfile=2; %else %if &state le 45 %then %let zipfile=3; %else %let zipfile=4; filename indata pipe "unzip -p /pub/data/popests/rawdata/icenA1_&zipfile..zip icenA1_&zipfile..txt"; data &dataset (label="&ustab Pop Ests, NCHS by Single Yrs of Age, Bridged Race, Sex & Hispanic, 1990-1999" compress=&compress); infile indata stopover; length State $2 County $5 Age $2 Race $1 Sex Hispanic $1 PopJl90 - PopJl99 4; input State $1-2 @; if state gt "&state" then stop; if state="&state"; *<=============processing state subset ===================================; input _co3 $3-5 @6 Age $char2. _racesex 1. Hispanic $1. (PopJl90 - PopJl99)(8.); County=State||_co3; /* =======================Begin comment================ if _co3 gt '009' then stop; if _co3='009' and _racesex=7 and hispanic='1'; *<===============; file saveraw; ***put _infile_; ======================End comment================== */ 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 popjl90='Pop Estimate July, 1990' popjl91='Pop Estimate July, 1991' popjl92='Pop Estimate July, 1992' popjl93='Pop Estimate July, 1993' popjl94='Pop Estimate July, 1994' popjl95='Pop Estimate July, 1995' popjl96='Pop Estimate July, 1996' popjl97='Pop Estimate July, 1997' popjl98='Pop Estimate July, 1998' popjl99='Pop Estimate July, 1999' ; drop _:; run; filename indata clear; options ls=166 ps=90; proc tabulate data=&dataset ; by state; *where age in ('00','60') and race='1' and sex='1' and hispanic='1'; class county; format county $county12. state $state.; var popjl: ; table county, (popjl90 popjl91 popjl98 popjl99) * sum*f=comma9.; title2 "Pop Sums for &dataset"; run; options ls=132 ps=60; %mend doit; %dostates(46); *<---South Dakota was empty because of a bug that looked for the data in the wrong .zip file-; /* =======================Begin comment================ %dostates(06 17 20 26 29 36 48,names=1); %dostates(12,names=1); %dostates(01 02 04 05 08 09 10 11 13 15 16 18 19 21 22 23 24 25 27 28 29 30,names=1); %dostates(31 32 33 34 35 37 38 39 40 41 42 44 45 46 47 49 50 51 53 54 55 56,names=1); ======================End comment================== */