%macro sdcpro3(setin=, /* name of input data set. If blank program will merge 3 sets based on &stab */ sumlev=,stab=,profiles=,pages=, outlib=%str(/pub/webrepts/sdcprofiles3/&stab), outname=, logrecno=0, /* specify the logical rec no and program will read the single obs. */ filter=, /* name of filter macro. Ignored if logrecno specified*/ CumulPaging=1,geocomps=00, RevDate=30Sep02, debug=0); /* Adapted from MainsSF3.sas by Roy Williams, Mass. SDC (MISER). by John Blodgett, Missouri Census Data Center. ------*/ %put ***sdcpro3 macro Rev. &revdate begins execution ****; OPTIONS LINESIZE=149 PAGESIZE=64 PAGENO=1 NODATE NONUMBER ORIENTATION=LANDSCAPE ; %local pages1 pages2 pagesA pagesD pagesE pagesF pagesH pagesI pagesJ pagesL pagesM pagesP pagesT ; %* credit line becomes bottom line on every page (<==customize for your state) ; %if %superq(credline) eq %str() %then %do; %LET credline=%STR(Prepared by the Missouri Census Data Center (MCDC), http://mcdc.missouri.edu) ; %let credline=&credline.. Generated using software created by a coalition of SDC agencies.; %end; %global credling lastline; %if %superq(credling) ne %str() %then %let credline=&credling; FILENAME Codelib "/pub/data/sf32000/sdcprofiles"; *<== probably edit only once ; **LIBNAME sf3 "/pub/data/sf32000" access=readonly; *<== Mod 9-6-02: Assume this defined in invoking pgm-; *--code and comments to invoke proc template and create the sf3style deleted here-; TITLE ; * Blanks out "The SAS System" title in ODS output ; *ODS ps file="&outlib/&sumlev._&profiles..ps" pdfmark style=SF3style ; * <== edit psfile parm, above; %if %superq(outname)=%str() %then %let outname=&sumlev._&profiles; %let outname=&outname; %*--resolve stuff if needed-; ODS printer pdf file="&outlib/&outname..pdf" NOTOC pdfmark style=SF3style ; %if %length(&profiles)=1 %then %let pages&profiles=&pages; %* Macro which PUTs centered title & a brief mnemonic on line 1 of every page ; %Macro PutTitle ( Title, Mnemonic) ; %* gets invoked by every page ; _Ltitle=LENGTH("&Title" ) ; %*--calculate column for centering title in 149-char line--; _TitleCol=FLOOR( (149 -_Ltitle)/2 ); %*--calculate column for right-justifying mnemonic in 149-char line--; _MnemCol = 150 -LENGTH("&Mnemonic" ) ; PUT #1 @_TitleCol "&Title" @_MnemCol "&Mnemonic" ; %mend PutTitle; %let profiles=%upcase(&profiles); %if &profiles=%str() or &profiles=ALL %then %let profiles=12ADEFHIJLMPT; DATA _null_ ; length state stab $2 county $5 geocomp $2; %*<---In case not on the input set--; %if &setin=%str() %then %do; MERGE sf3.&stab.ph sf3.&stab.phct sf3.&stab.phctR ; BY LogRecNo ; %end; %else %do; SET &setin ; %end; %if &logrecno ne 0 %then %do; where logrecno=&logrecno; %end; %else %if &filter=%str() %then %do; where SumLev="&sumlev"; %end; %else %&filter; %if &logrecno=0 and &geocomps ne %str() %then %do; if index("&geocomps",geocomp); %end; FILE PRINT LINESIZE=149 PAGESIZE=65 N=PAGESIZE NOTITLES; LENGTH _PAGES $11 profiles $13; RETAIN profiles "&profiles" ; AreaCount+1; *---------------------------------------------------------------------------------------- ; IF AreaCount LE 199 OR MOD(AreaCount,50)=0 THEN DO ; FILE LOG; PUT Pop100= GeoCode= AreaName= ; FILE PRINT; END ; RETAIN strtline 6 RunPage 0 ; * if cumulative page numbering is set to false, each area will start with page 1 ; IF (&CumulPaging=0) THEN RunPage=0 ; LENGTH Underline DoubleLine SingleLine $149 ; RETAIN Underline DoubleLine SingleLine VBAR '|' PLUS '+' _first 1; IF _first THEN DO; RunDate="&sysdate"; RETAIN RunDate; UnderLine= REPEAT('_',147) ; DoubleLine=REPEAT('=',147) ; SingleLine=REPEAT('-',147) ; ***profiles=SYMGET('PROFILES'); ***IF profiles=' ' or profiles='ALL' THEN profiles='12ADEFHIJLMPT'; _first=0 ; * (i.e. false) ; END; * IF (TOC>1 or (TOC=1 AND AreaCount=1)) THEN LINK PageTOC ; * no Table of Contents yet ; *Note that _pages gets a value intended (!) to be local to each routine ; %IF %INDEX(&PROFILES,1)%then %do; ProfID='Primary'; _PAGES="&pages1"; LINK PrimeProf; IF _ERROR_ THEN LINK err; %end; %IF %INDEX(&PROFILES,2)%then %do; ProfID='2ndary'; _PAGES="&pages2"; LINK secprof; IF _ERROR_ THEN LINK err; %end; %IF %INDEX(&PROFILES,A)%then %do; ProfID='Ancestry'; _PAGES="&pagesA"; LINK AncyProf; IF _ERROR_ THEN LINK err; %end; %IF %INDEX(&PROFILES,D)%then %do; ProfID='Disability'; _PAGES="&pagesD"; LINK DisProf; IF _ERROR_ THEN LINK err; %end; %IF %INDEX(&PROFILES,E)%then %do; ProfID='Educ'; _PAGES="&pagesE"; LINK EducProf; IF _ERROR_ THEN LINK err; %end; %IF %INDEX(&PROFILES,F)%then %do; ProfID='Family'; _PAGES="&pagesF"; LINK familyprof; IF _ERROR_ THEN LINK err; %end; %IF %INDEX(&PROFILES,H)%then %do; ProfID='Housing'; _PAGES="&pagesH"; LINK HousProf; IF _ERROR_ THEN LINK err; %end; %IF %INDEX(&PROFILES,I)%then %do; ProfID='Income'; _PAGES="&pagesI"; LINK IncProf; IF _ERROR_ THEN LINK err; %end; %IF %INDEX(&PROFILES,J)%then %do; ProfID='Jobs'; _PAGES="&pagesJ"; LINK JobsProf; IF _ERROR_ THEN LINK err; %end; %IF %INDEX(&PROFILES,L)%then %do; ProfID='Language'; _PAGES="&pagesL"; LINK LangProf; IF _ERROR_ THEN LINK err; %end; %IF %INDEX(&PROFILES,M)%then %do; ProfID='Migration'; _PAGES="&pagesM"; LINK migrprof; IF _ERROR_ THEN LINK err; %end; %IF %INDEX(&PROFILES,P)%then %do; ProfID='Poverty'; _PAGES="&pagesP"; LINK povprof; IF _ERROR_ THEN LINK err; %end; %IF %INDEX(&PROFILES,T)%then %do; ProfID='Transport'; _PAGES="&pagesT"; LINK tranprof; IF _ERROR_ THEN LINK err; %end; RETURN; *---end main routine. Now come the linked-to routines---; err: *---Handles errors encountered while generating profiles---; FILE LOG; _nerr+1; IF _nerr LE 20 THEN PUT '** Error detected (probably division by zero) ' 'during processing of profile ' ProfID ' for ' AREANAME; _ERROR_=0; ** turn off flag, avoid dump **; IF _nerr EQ 20 THEN DO; PUT // '** NO MORE OF THESE MESSAGES WILL BE PRINTED **'; END; FILE PRINT; RETURN; *<---main program loop ends with above return stmt. The following include statements reference the Codelib library where the links to generate the profiles reside--; **options mlogic symbolgen; %if %index(&profiles,1) %then %str(%include Codelib(PrimeProf.sas);); %*--Julie Hoang, California (with help from Jeff & Xan)--; %if %index(&profiles,2) %then %str(%include Codelib(secprof.sas);); %*--Xan Stevens, Kansas--; %if %index(&profiles,A) %then %str(%include Codelib(AncyProf.sas) ;); %*--Roy Williams, Massachusetts; %if %index(&profiles,D) %then %str(%include Codelib(Disprof.sas);); %*--Phyllis Smith, Amrut K., et al, Arkansas--; %*---mcdc-Edited version!--; %if %index(&profiles,E) %then %str(%include Codelib(EducProf.sas) ;); %*--Jeff Wallace, Oklahoma--; %if %index(&profiles,F) %then %str(%include Codelib(familyprof.sas) ;); %*--Amy Chen, Maryland--; %if %index(&profiles,H) %then %str(%include Codelib(HousProf.sas) ;); %*--Julie Hoang, California (with help from Jeff)--; %if %index(&profiles,I) %then %str(%include Codelib(IncProf.sas) ;); %*--Annette Boyer, Colorado--; %if %index(&profiles,J) %then %str(%include Codelib(JobsProf.sas) ;); %*--Roy Williams, Massachusetts--; %if %index(&profiles,L) %then %str(%include Codelib(LangProf.sas) ;); %*--Annette Boyer, Colorado--; %if %index(&profiles,M) %then %str(%include Codelib(migrprof.sas) ;); %*--Jeff Wallace, Oklahoma--; %if %index(&profiles,P) %then %str(%include Codelib(Povprof.sas) ;); %*--Phyllis Smith, Amrut K., et al, Arkansas--; %if %index(&profiles,T) %then %str(%include Codelib(tranprof.sas) ;); *--Jeff Wallace, Oklahoma--; HeadFoot: /* This routine is invoked after the body of each profile page is complete. Puts the headers, footers and the big outer box. Centered TITLE & brief mnemonic already PUT in line #1 by above routines. */ PUT #1 'Census 2000, Summary File 3' ; IF geocomp EQ '00' | geocomp=' ' THEN PUT #2 'Area Name: ' AreaName ; ELSE PUT #2 'Area: ' AreaName 'Geo. Component:' geocomp $geocomp. ; LENGTH TypeString $ 60 ; TypeString='Area Type: '||TRIM(PUT(SumLev,$SumLev.))|| ' (Summary Level '||SumLev||')' ; PUT #2 @(150 - LENGTH(TypeString)) TypeString ; LENGTH GeoString $149 ; GeoString=' ' ; IF (StAb NE ' ') THEN GeoString='State: '||UPCASE(StAb) ; IF (cnty NE ' ') THEN DO ; GeoString=TRIM(GeoString)||' County: '||cnty ; IF (SumLev NE '050' ) THEN geostring= TRIM(geostring)||' ('||TRIM(PUT(county,$county.))||')'; END ; IF (CouSubFP NE ' ') THEN GeoString=TRIM(GeoString)||' CouSub: '||CouSubFP ; IF (PlaceFP NE ' ') THEN GeoString=TRIM(GeoString)||' Place: '||PlaceFP ; IF (Tract NE ' ') THEN GeoString=TRIM(GeoString)||' Tract: '||Tract ; IF (BG NE ' ') THEN GeoString=TRIM(GeoString)||' BG: '||BG ; IF (MSACMSA NOT IN (' ','####','9999')) THEN DO ; IF (CMSA2 = '99') THEN GeoString=TRIM(GeoString)||' MSA: '||MSACMSA ; ELSE DO ; GeoString=TRIM(GeoString)||' CMSA: '||MSACMSA ; IF (PMSA NE ' ') THEN GeoString=TRIM(GeoString)||' PMSA: '||PMSA ; END ; END ; IF (UA NOT IN (' ','9999')) THEN GeoString=TRIM(GeoString)||' UA: '||UA ; IF (CD106 NE ' ') THEN GeoString=TRIM(GeoString)||' CD106: '||CD106 ; *---Mods by JGB 11/02 to handle revised state legislative districts and cd108--; IF (CD108 NE ' ') THEN GeoString=TRIM(GeoString)||' CD108: '||CD108 ; if sldl02 ne ' ' then sldl=sldl02; if sldu02 ne ' ' then sldu=sldu02; IF (sldl NE ' ') THEN GeoString=TRIM(GeoString)||' State House District: '||sldl ; IF (sldu NE ' ') THEN GeoString=TRIM(GeoString)||' State Senate District: '||sldu ; IF (Urbanrur NE ' ') THEN GeoString=TRIM(GeoString)||' Urban/Rural: '||UrbanRur ; * There is plenty of room to display additional geocodes as needed-- just concatenate them onto GeoString as above ; if geostring=' ' then geostring='ff'x; *<---placeholder---; PUT #3 GeoString ; *---Draw the box around the tabular area incl left and right vertical lines--; PUT #5 @1 PLUS $1. DoubleLine $147. PLUS $1. ; DO _I_=6 TO 61; PUT #_I_ @1 VBAR $1. @149 VBAR $1. @; END ; *----Footers including bottom of box--------; RunPage + 1 ; * Cumulative paging for this run: (# of areas) x (# of profiles) ; LENGTH credline $148 ; RETAIN credline "&credline"; PUT #62 @1 PLUS $1. DoubleLine $147. PLUS $1. / @1 "Source: Census 2000 Summary File 3 [machine-readable data file]/prepared" " by the U.S.Census Bureau, 2002 (www.census.gov)" @123 RunDate +(-1) ': Area ' AreaCount : 3.0 +(-1) ', Page ' RunPage 3.0-L / @1 credline %if %superq(lastline) ne %str() %then %do; / @1 "&lastline"; %end; %else %do; / @45 "Report stored in &outlib/&outname..pdf"; %*--EXTRA LINE FOR MCDC--; %end; RETURN; *************end HeadFoot routine**************; RUN; *ODS ps close ; ods printer close; %mend sdcpro3;