x cd /mscdc/data/stp154/Tools; %let pgm=stp154; filename pgm "&pgm..sas"; %let data=/mscdc/data/stp154; libname stp154 "&data"; libname temp '/tmp/gaussian/stp154'; title 'Convert STP154 Data (journey-to-work by tract & place) for ' 'United States'; *<===========; *-- nmk, 5/4/95; filename in '/tmp/gaussian/stp154'; options msglevel=i nocenter; *---process the data. access input files for all states ---*; *-- putting full us data in /tmp/gaussian/stp154 - no indices being created --; data temp.us (label='STP154 - US DATA' sortedby=wstate wcounty); length nowread $ 30; input nowread $ ;*<=== This input statement reads value from cards which contains list of input files and assigns it to NOWREAD; infile in filevar=nowread end=done; *<==== This infile statement closes current file and opens new one if value of NOWREAD has changed when infile statement executes; do until(done); length default=4; *-- This input statement reads from currently open input file; input wstate $1-2 wcounty $1-5 wtractin $6-11 wmcd $12-14 wplace $15-18 rstate $20-21 rcounty $20-24 rtractin $25-30 rmcd $31-33 rplace $34-37 +1 (workers watract waplace wacomcd)(6.); length wtract rtract $7; wtract=substr(wtractin,1,4)||'.'||substr(wtractin,5,2); rtract=substr(rtractin,1,4)||'.'||substr(rtractin,5,2); label wstate='FIPS state code, place of work' wcounty='County of work' wtract='Tract of work' wmcd='MCD of work (New Eng)' wplace='Place (city) of work' rstate='FIPS state code, place of residence' rcounty='County of residence' rtract='Tract of residence' rmcd='MCD of residence (New Eng)' rplace='Place (city) of residence' workers='Count of workers, inc. allocs' watract='Workers allocated to wtract' waplace='Workers allocated to wplace' wacomcd='Workers allocated to wmcd'; drop wtractin rtractin; output; end; cards; /tmp/gaussian/stp154/stp154.01 /tmp/gaussian/stp154/stp154.02 /tmp/gaussian/stp154/stp154.04 /tmp/gaussian/stp154/stp154.05 /tmp/gaussian/stp154/stp154.06 /tmp/gaussian/stp154/stp154.08 /tmp/gaussian/stp154/stp154.09 /tmp/gaussian/stp154/stp154.10 /tmp/gaussian/stp154/stp154.11 /tmp/gaussian/stp154/stp154.12 /tmp/gaussian/stp154/stp154.13 /tmp/gaussian/stp154/stp154.15 /tmp/gaussian/stp154/stp154.16 /tmp/gaussian/stp154/stp154.17 /tmp/gaussian/stp154/stp154.18 /tmp/gaussian/stp154/stp154.19 /tmp/gaussian/stp154/stp154.20 /tmp/gaussian/stp154/stp154.21 /tmp/gaussian/stp154/stp154.22 /tmp/gaussian/stp154/stp154.23 /tmp/gaussian/stp154/stp154.24 /tmp/gaussian/stp154/stp154.25 /tmp/gaussian/stp154/stp154.26 /tmp/gaussian/stp154/stp154.27 /tmp/gaussian/stp154/stp154.28 /tmp/gaussian/stp154/stp154.29 /tmp/gaussian/stp154/stp154.30 /tmp/gaussian/stp154/stp154.31 /tmp/gaussian/stp154/stp154.32 /tmp/gaussian/stp154/stp154.33 /tmp/gaussian/stp154/stp154.34 /tmp/gaussian/stp154/stp154.35 /tmp/gaussian/stp154/stp154.36 /tmp/gaussian/stp154/stp154.37 /tmp/gaussian/stp154/stp154.38 /tmp/gaussian/stp154/stp154.39 /tmp/gaussian/stp154/stp154.40 /tmp/gaussian/stp154/stp154.41 /tmp/gaussian/stp154/stp154.42 /tmp/gaussian/stp154/stp154.44 /tmp/gaussian/stp154/stp154.45 /tmp/gaussian/stp154/stp154.46 /tmp/gaussian/stp154/stp154.47 /tmp/gaussian/stp154/stp154.48 /tmp/gaussian/stp154/stp154.49 /tmp/gaussian/stp154/stp154.50 /tmp/gaussian/stp154/stp154.51 /tmp/gaussian/stp154/stp154.53 /tmp/gaussian/stp154/stp154.54 /tmp/gaussian/stp154/stp154.55 /tmp/gaussian/stp154/stp154.56 ; run; title2 'Sample of observations from STP154 US data set'; proc print data=temp.us (obs=50); run; title2; proc contents data=temp.us; run; *-- Aggregate US dataset by worker state, county and tract. Aggregating workers and allocated workers; /*-- commenting out - don't need ------------ proc sort data=temp.us out=aggin; by wcounty wtract ; run; ------------- end comment out ----------------*/ %agg(aggin=temp.us,aggout=aggout, aggby=wcounty wtract , aggvars=workers watract, idvars=wstate) *-- Create final aggregated data set with one observation for each tract and variables showing number of workers and calculated percentage of workers allocated to each tract--; data stp154.uswttots (label='US Work Tract Totals' sortedby=wstate wcounty index=(wstate wcounty)); set aggout; length pcta 3 ; format pcta 5.1; pcta=(watract/workers)*100; keep wstate wcounty wtract workers pcta; label pcta='Pct Workers Allocated to Tract'; run; title2 'Sample of observations from STP154 US totals data set'; proc print data=stp154.uswttots (obs=50); run; title2; proc contents data=stp154.uswttots position; run;