x cd /mscdc/data/stf9s5/Tools; %let pgm=commuting_patterns; filename pgm "&pgm..sas"; *--modeled after the STF9S5X1 (in applctns library) job coded for MVS back in '93 . Generates a report showing commuting patterns at county level for a specified state. ---*; libname stf9s5 '/mscdc/data/stf9s5' access=readonly; %let state=10; %let stname=Delaware; *<---this was our test state. Only 3 counties-; %let state=17; %let stname=Illinois; %let state=29; %let stname=Missouri; %let state=20; %let stname=Kansas; %let filename=&stname._commuting_patterns.report; TITLE "Commuting Patterns Report for &stname"; filename report "/mscdc/data/stf9s5/&filename"; proc printto print=report new; run; *--the proc print steps write to the report file; title2 'Source: 1990 U.S. Census: Special Tabulation File S5'; footnote1 'Only counties with at least 250 commuters are reported in detail'; data report; set stf9s5.us; where rstate="&state"; length workloc $32; if nworkers ge 250 then do; workloc=put(wcounty,$county.); end; else if wstate ="&state" then workloc="Other county in &stname"; else workloc="Other outside &stname"; keep rcounty workloc nworkers; label workloc='County of Work' rcounty='County of Residence' nworkers='# Commuters' ; format rcounty $county18.; run; proc sort; by rcounty workloc; %corrwt(setin=report, geocds1=rcounty,geocds2=workloc,weight=nworkers, keepwt=1,setout=byres) proc sort data=byres; by rcounty descending nworkers; run; *---ready to generate part 1 of report---; options linesize=80 pagesize=79 nodate; proc print label data=byres; by rcounty notsorted; id rcounty; var workloc nworkers afact; format nworkers comma12.; format afact percent7.1; label afact='Pct'; title3 'Part 1: Sorted by County of Residence'; run; options pageno=1; data report2; set stf9s5.us; length resloc $32; where wstate=:"&state"; if nworkers ge 250 then do; resloc=put(rcounty,$county.); end; else if rstate="&state" then resloc="Other county in &stname"; else resloc="Other outside &stname"; keep wcounty resloc nworkers; label resloc="County of Residence" wcounty="County of Work"; label nworkers='# Commuters' ; format wcounty $county18.; run; proc sort; by wcounty resloc; run; %corrwt(setin=report2, geocds1=wcounty,geocds2=resloc,weight=nworkers, keepwt=1,setout=bywork) proc sort data=bywork; by wcounty descending nworkers; run; options linesize=79 nodate pageno=1; proc print label data=bywork; by wcounty notsorted; id wcounty; var resloc nworkers afact; format nworkers comma12.; format afact percent7.1; label afact='Pct'; title3 "Part 2: Sorted by County of Work"; run; *--create a soft link to the report file from the /mscdc/reports directory--; x ln -s /mscdc/data/stf9s5/&filename /mscdc/reports/commuting_patterns/&stname; x contents -u; x cd /mscdc/reports; x contents -u;