%macro sdcpro1(setin=, /* name of input data set. If blank program will merge 2 sets based on &stab */ merge=1,/* specify merge=0 along with setin to just access &setin instead of merging &setin.ph and &setin.pct*/ mergeby=logrecno, /* what to merge by */ sumlev=, geocode=, stab=, profiles=126, outlib=%str(/pub/webrepts/sdcprofiles1/&stab.pdfs), 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=06Nov02b, pages1=123, pages2=123,pages6=1234,pages=, geocomps=00, debug=0); /* Adapted from sdcpro3 which was adapted from MainsSF3.sas by Roy Williams, Mass. SDC (MISER) which was adapted from our orginal main routine for the sf1profiles. by John Blodgett, Missouri Census Data Center. ------*/ %put ***sdcpro1 macro Rev. &revdate begins execution ****; OPTIONS LINESIZE=149 PAGESIZE=64 PAGENO=1 NODATE NONUMBER ORIENTATION=LANDSCAPE ; %local linesize pagesize; %let linesize=149; %let pagesize=64; *<--these really do not vary-; %* 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 lastline; FILENAME Codelib "/pub/data/sf12000/sf1pros"; *<== probably edit only once ; libname sf1 "/pub/data/sf12000" access=readonly; *--code and comments to invoke proc template and create the sf3style deleted here-; TITLE ; * Blanks out "The SAS System" title in ODS output ; %if %superq(outname)=%str() %then %let outname=&sumlev._&geocode; *<---Assign default output name--; %let outname=&outname; %*--resolve stuff if needed-; ODS printer pdf file="&outlib/&outname..pdf" NOTOC pdfmark style=SF3style ; %if %length(&profiles)=1 and &pages ne %str() %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 &merge %then %do; %if %bquote(&setin)=%str() %then %let setin=&stab; MERGE sf1.&setin.ph sf1.&setin.pct ; BY &mergeby; %end; %else %do; SET &setin ; %end; %if &logrecno ne 0 %then %do; where logrecno=&logrecno; %end; %else %if %bquote(&geocode) ne %str() %then %do; where SumLev="&sumlev" and geocode="&geocode"; %end; %else %if &filter=%str() %then %do; where SumLev="&sumlev"; %end; %else %&filter; %if &logrecno=0 and &geocomps ne %str() %then %do; if geocomp ne ' ' then if index("&geocomps",geocomp); %end; FILE PRINT LINESIZE=149 PAGESIZE=65 N=PAGESIZE NOTITLES; LENGTH 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 PCT = . then PCT=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; length _pages $16 title $100; IF INDEX(PROFILES,'1')THEN DO; pno='1'; TITLE='Primary Profile'; _pages="&pages1"; LINK GenProf1; IF _ERROR_ THEN LINK err; END; IF INDEX(PROFILES,'2')THEN DO; pno='2'; TITLE='Supplementary Profile'; _pages="&pages2"; LINK GenProf2; IF _ERROR_ THEN LINK err; END; IF INDEX(PROFILES,'3')THEN DO; pno='3'; TITLE='Age Profile'; _pages="&pages3"; LINK GenProf3; IF _ERROR_ THEN LINK err; END; IF INDEX(PROFILES,'4')THEN DO; pno='4'; TITLE='Detailed Age Profile'; _pages="&pages4"; LINK GenProf4; IF _ERROR_ THEN LINK err; END; IF INDEX(PROFILES,'5')THEN DO; pno='5'; TITLE='Race Profile'; _pages="&pages5"; LINK GenProf5; IF _ERROR_ THEN LINK err; END; IF (INDEX(PROFILES,'6') AND PCT)THEN DO; * dont bother for bg/block ; pno='6'; TITLE='Group Quarters Profile'; _pages="&pages6"; LINK GenProf6; 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) ' 'while processing profile ' PNO ' 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--; *<------------Getting undebuggable message when we tried to include this code so we just bring it right inline here and see what happens. jgb, 11-6-02-----; %INCLUDE codelib(GenProf1) ; *--Phyllis Smith, Arkansas.--; %INCLUDE codelib(GenProf2) ; *--Jeff Wallace, Oklahoma.--; *INCLUDE codelib(GenProf3) ; *-- --; *INCLUDE codelib(GenProf4) ; *-- --; *INCLUDE codelib(GenProf5) ; *-- --; *<====Replace these place-holders with the include code when module is here==; *----Replace these placeholder labels with the corresponding include stmts---; GenProf3: return; GenProf4: return; GenProf5: return; %INCLUDE codelib(GenProf6) ; *--Roy Williams, Massachusetts--; HeadFoot: /* This routine is invoked after the body of each profile page is complete. Puts the headers, footers and vertical lines on either side. Rest of line #1 (centered TITLE) already PUT in by GenProfx. Primary author: Roy W. */ PUT #1 'Census 2000, Summary File 1' ; ***Comment out the areacount*** @(&linesize-6) 'Area' AreaCount 3.0 ; if geocomp in( '00',' ') then put #2 'Area Name: ' AreaName ; else put #2 'Area: ' AreaName 'Component:' geocomp $geocomp. ; *<===Comment out above else statement if you are not interested in geocomp summaries. Must have defined the $geocomp. format-; * should test for presence of sumlev in $sumlev. ; LENGTH TypeString $ 60 ; TypeString='Area Type: '|| TRIM(PUT(SumLev,$SumLev.))||' (Summary Level '||SumLev||')' ; IF geocomp NE '00' THEN DO ; *** Already identified this after areaname, above. TypeString=TRIM(TypeString)||' Geo. Component: '||geocomp; END ; *<=== Users may want to build TypeString using LSADC along with SumLev for some kinds of areas--it has more specific categories (Parishes, Boroughs, etc.) ; PUT #2 @(%eval(&linesize+1) - LENGTH(TypeString)) TypeString ; LENGTH GeoString $&linesize ; GeoString=' ' ; IF (StAb NE ' ') THEN GeoString='State: '||UPCASE(StAb) ; IF (cnty NE ' ') THEN DO ; GeoString=TRIM(GeoString)||' County: '||cnty ; * user will need to have the $county. format source code--; 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 ' ' and Block EQ ' ' ) THEN GeoString=TRIM(GeoString)||' BG: '||BG ; IF (Block NE ' ') THEN GeoString=TRIM(GeoString)||' Block: '||Block ; * still need to add UA., MSA, etc. to GeoString ; if GeoString=' ' then Geostring='Geo Code: '|| geocode; PUT #3 GeoString ; *---Leaving Line 4 blank at this point, but we may need to change our minds--; *---Draw the box around the tabular area incl left and right vertical lines--; PUT #5 @1 PLUS $1. DoubleLine $%eval(&linesize-2). PLUS $1. ; DO _I_=strtline TO %EVAL(&pagesize-3); PUT #_I_ @1 VBAR $1. @&linesize VBAR $1. @; END ; *----Footers including bottom of box--------; RunPage + 1 ; * Cumulative paging for this run: (# of areas) x (# of profiles) ; LENGTH credline $%EVAL(&linesize-1); RETAIN credline "&credline"; PUT #%eval(&pagesize-2) @1 PLUS $1. DoubleLine $%eval(&linesize-2). PLUS $1. / #%eval(&pagesize-1) @1 "Source: Census 2000 Summary File 1 [machine-readable data file]/prepared" " by the U.S.Census Bureau, 2001 (www.census.gov)" @(&linesize-17) RunDate +(-1) ', Page ' RunPage 4.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; ; PUT _PAGE_ ; RETURN; *************end HeadFoot routine**************; RUN; ods printer close; %mend sdcpro1;