< %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=06
<   06Sep02,
<   debug=0);
> /*----- "MainSF3.SAS", SDC 2000 SF3 Profiles Main Routine which reads a SAS data
>  set and generates individual profile pages as specified by user parameters.  Part
>  of the joint SF3 Profiles project of the national State Data Center network,
>  Spring, 2002.  Based on the similar routine for SF1 profiles coded by
>  John Blodgett, OSEDA/U. of Missouri, & Roy Williams, MISER/UMass  (413)545-3460
  
< /* Adapted from MainsSF3.sas by Roy Williams, Mass. SDC (MISER).
<    by John Blodgett,  Missouri Census Data Center.
>   6/10/02: Initial shell extracted from Main[SF1]
>   6/17/02: added module/page selection logic
>   7/15/02: added PROC TEMPLATE & ODS PS to allow direct output to PostScript (for pdf)
>            Output is also written to the standard FILE PRINT (Output window or equivalent.)
>   8/07/02: Initial release on the SDC Clearinghouse web site
>   8/14/02: added explicit PROC FORMAT LIBRARY=LIBRARY run & some more comments
>   8/27/02: added list of extract data sets for Massachusetts (substitute your state abbrev.)
>   9/13/02: added Table of Contents (2 pages)
  ------*/
<  %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 ;
> %GLOBAL stab profiles pages1 pages2 pagesA pagesD pagesE pagesF pagesH pagesI pagesJ pagesL
>           pagesM pagesP pagesT geocomps CumulPaging ;
> %*  credit line becomes bottom line on every page (<==customize for your state) ;
> %LET credline=
> %STR(Profile prepared by the Massachusetts State Data Center (MISER),
> UMass/Amherst    (413)545-3460     www.umass.edu/miser     miser@miser.umass.edu);
> %LET ToC=2 ; %* <== controls Table of Contents: set ToC=0 to suppress completely, set ToC=1
> to get one Table of Contents at beginning of run, set ToC>1 for a ToC with every profile ;
> 
> %LET CumulPaging=1 ; %* <== turns on cumulative paging for this run (your preference) ;
  
< %*  credit line becomes bottom line on every page (<==customize for your state) ;
< %LET credline=%STR(Prepared by the Missouri Census Data Center (MCDC), http://mcdc.missouri.edu) ;
< %let credline=&credline. using software created by a coalition of SDC agencies.;
> * where the page module code is stored-- ;
> FILENAME SASCode "J:\Cens2000\sf3\Profiles Project"; * (<== probably edit only once) ;
  
< %global credling lastline;
< %if %superq(credling) ne %str() %then %let credline=&credling;
> * LIBNAME sf3 is where the data set(s) are stored (<== edit as needed) ;
> LIBNAME sf3 "J:\Cens2000\sf3\ma\" ;
> * LIBNAME sf3 "C:\sf3\Test\" ;
  
< FILENAME Codelib "/pub/data/sf32000/sdcprofiles"; *<== probably edit only once ;
> * LIBNAME LIBRARY is for stored formats $County.,$SumLev., & $GeoComp. When you run Proc Format
> they get stored in "formats.sas7bcat" (under Windows at least)-- the 3 VALUE statements %INCLUDE'd
> below are part of the package.  LIBNAME LIBRARY doesn't have to be the same as LIBNAME sf3 ;
> LIBNAME LIBRARY "J:\Cens2000\sf3\Profiles Project";  * (<== edit as needed) ;
> /* uncomment this and run once to store the formats in LIBRARY (or take out LIBRARY=LIBRARY and run
> every time--in that case it will create "formats.sas7bcat" in your WORK location) ;
> PROC FORMAT LIBRARY=LIBRARY ;
> %INCLUDE SASCode(County.sas) ;
> %INCLUDE SASCode(SumLev.sas) ;
> %INCLUDE SASCode(GeoCompBrief.sas) ;
> RUN ; */
  
< **LIBNAME sf3 "/pub/data/sf32000" access=readonly;    *<== Mod 9-6-02: Assume this defined in invoking pgm-;
> * That's almost it for paths (there's one more in the ODS statement below.)  Most user parameters
> are macro vars (%LET...) established before the big DATA _NULL_ step, but users do need to
> edit the data set name(s) (SET or MERGE statement), the geographic selection (WHERE statement,
> etc.) and an optional stopping criterion (IF whatever, THEN STOP).  
> If there's anything else, let me know! ;
  
< *--code and comments to invoke proc template and create the sf3style deleted here-;
> %INCLUDE SASCode(SF3Template.sas) ; * runs Proc Template: creates the ODS style 
>   "SF3style" to allow direct output to the ODS PostScript Destination.  
>   Selecting PostScript instead of pdf gets around an indentation/alignment bug
>   in the SAS Version 8.2 ODS PDF implementation, but it means the user must run 
>   Adobe Distiller to "distill" the resulting file from ps to pdf.  Distiller automatically
>   saves "name.pdf" in the same location as "name.ps".  Turning on the "pdfmark" option will
>   allow adding pdf bookmarks later, or so I'm told. Haven't tried it yet.  
> Proc Template actually needs to be run only once, since the style will automatically
>   get saved in a SASUSER location.  SAS Version 8.2 doesn't allow for hard page breaks
>   in ODS "batch" print output, but these margins cause appropriate breaks every 64 lines,
>   at least on my Windows2000 machine here at MISER with Adobe Acrobat 5.0 ;
  TITLE ; * Blanks out "The SAS System" title in ODS output ;
< *ODS ps
< file="&outlib/&sumlev._&profiles..ps" pdfmark style=SF3style ; * <== edit psfile parm, above;
> ODS ps file="J:\Cens2000\sf3\Profiles Project\FullMAwTOC.ps" pdfmark style=SF3style ; * <== edit each time ;
> 
> %LET stab=ma; * <== which state's files to access (<== edit as needed--used only by MERGE statement) ;
  
<  %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 ;
> * which profiles--leave blank or null to select all (can't use "ALL" --that would get only
>  Ancestry & Language!) See IF(INDEX(... statements below for meaning of the 1-char mnemonics;
> %LET profiles=; * (same as saying %LET profiles='12ADEFHIJLMPT') ; * <== edit each time ;
> *%LET profiles=12hi ; * requests Primary, 2ndary, Housing & Income (lower case now OK) ;
  
> * selecting pages--leave blank or null or use "ALL" to select all (use A for page10
>  & B for page11 of the Primary module)  The ones you don't mention are null by default ;
> * examples of how to select fewer than all pages of a module-- ;
> %*LET pagesI=1234 ; * page 1 to 4 of Income ; * (<== edit as needed) ;
> %*LET pages1=89ab ; * pages 8, 9, 10 & 11 of Primary ;
> /* %LET pages1=18a ; %LET pagese=1 ; %LET pagesh=1 ; %LET pagesf=1 ; %LET pagest=1 ; */
> %* Note for interactive mode users: Global macro vars automatically retain a value across data
>  steps during an interactive session.  You generally will need to reset "profiles" and "pagesX"
>  before your next run.  For example if you had pages1=89AB in your last run and now you want
>  them all, you have to explicitly reset pages1 by setting it to null as shown (commented out) ;
> *%LET pages1= ;
  
< %if %length(&profiles)=1 %then %let pages&profiles=&pages;
> %LET geocomps=00 ;  *<===specify additional geocomp codes (2-digit, separated
>  by blanks) in the unlikely event that you want profiles for geog components
>  other than the default "00" (which means "NOT a geographic component")--;
  
  %* 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;
> %MEnd ;
  
<  %let profiles=%upcase(&profiles);
<  %if &profiles=%str() or &profiles=ALL %then %let profiles=12ADEFHIJLMPT;
< 
< DATA _null_ ;
<  %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;
> DATA _NULL_ ;
> * <==== EDIT data set selection HERE: only one SET or MERGE statement should be active ;
> /* Merging takes time--you may want to do it once and save extract files grouped by county or
> by SumLev or whatever.  Remember BG's only have P & H tables ;
> MERGE sf3.&stab.ph  sf3.&stab.phct  sf3.&stab.phctR ;
> BY LogRecNo ; */
> * Massachusetts extract sets by SumLev -- (zero-Pop100 areas deleted 8/30/02) ;
> SET sf3.s3MA060P ; * state, counties, MCD's ;
> * SET sf3.s3MA070 ; * place parts (within MCD...) ;     
> * SET sf3.s3MA080 ; * tract parts ;
> * SET sf3.s3MA085 ; * Urban/Rural parts of tracts ;
> * SET sf3.s3MA090 ; * Block Group parts--No PCT/HCT tables for Block Groups ;   
> * SET sf3.s3MA140 ; * whole tracts ;
> * SET sf3.s3MA150 ; * whole Block Groups--No PCT/HCT tables for Block Groups ;
> * SET sf3.s3MA160 ; * whole places ;
> * SET sf3.s3MAMSA ; * C/P/MSA's & some components ;
> * SET sf3.s3MAUA ; * Urbanized Areas & Urban Clusters ;
> * SET sf3.s3MA106C ; * Congressional Dists (106th) ;
> * SET sf3.s3MAZIP ; * ZCTA's actually ;
> * SET sf3.s3MAothr ; * Includes 144, 170, and 2xx ;
  
< %if &logrecno=0 and &geocomps ne %str() %then %do;
<   if index("&geocomps",geocomp);
<   %end;
> *  <==== EDIT Area selection HERE: at most one WHERE statement should be active ;
> * WHERE AreaName IN: ('Hamilton','Wenham') ;
> * WHERE SumLev =: '2' ; * all Native American SumLevs ;
> * WHERE LogRecNo = 1 ; * first record (state) only ;
> * WHERE 0<Pop100<200 ; * some very small town in Berkshire County ;
> * WHERE SumLev='420' & Pop100>100 & UAType='U' ; * Urbanized Areas (not the slivers) ;
  
< FILE PRINT LINESIZE=149 PAGESIZE=65 N=PAGESIZE NOTITLES;
> * to Display Manager window or its batch-mode equivalent--commenting this out caused problems ;
> FILE PRINT LINESIZE=149 PAGESIZE=64 N=PAGESIZE NOTITLES;
  LENGTH _PAGES $11  profiles $13;
< 
> %LET profiles=%UPCASE(&profiles) ; %* now people can use lower-case letters above ;
  RETAIN profiles "&profiles" ;
  AreaCount+1;
> * comment out the stopping criterion if you don't know how many to expect! ;
> IF AreaCount>1 THEN STOP ;
  
< *---------------------------------------------------------------------------------------- ;
> *-------------------------------------------------------------------------------------------
> Probably nothing needs to be edited after this point, but look it over once to get an idea
> what's going on.  You may want to tweak something to make it work the way YOU want it.!
> ------------------------------------------------------------------------------------------- ;
  
  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';
>   profiles=SYMGET('PROFILES');
>   IF profiles=' ' THEN profiles='12ADEFHIJLMPT'; * can't use ALL ;
     _first=0 ; * (i.e. false) ;
  END;
< * IF (TOC>1 or (TOC=1 AND AreaCount=1)) THEN LINK PageTOC ; * no Table of Contents yet ;
> IF (&TOC>1 or (&TOC=1 AND AreaCount=1)) THEN LINK PageTOC ;
  *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;
> 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
>  statements reference the SASCode 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--;
> OPTIONS NOSOURCE2 NOMPRINT ; *<====can flip switches for debugging----;
> %INCLUDE SASCode(PageTOC) ;    *--Roy Williams, Massachusetts--;
> %INCLUDE SASCode(PrimeProf) ;  *--Julie Hoang, California (with help from Jeff & Xan)--;
> %INCLUDE SASCode(secprof) ;    *--Xan Stevens, Kansas--;
> %INCLUDE SASCode(AncyProf) ;   *--Roy Williams, Massachusetts;
> %INCLUDE SASCode(Disprof) ;    *--Phyllis Smith, Amrut K., et al, Arkansas--;
> %INCLUDE SASCode(EducProf) ;   *--Jeff Wallace, Oklahoma--;
> %INCLUDE SASCode(familyprof) ; *--Amy Chen, Maryland--;
> %INCLUDE SASCode(HousProf) ;   *--Julie Hoang, California (with help from Jeff)--;
> %INCLUDE SASCode(IncProf) ;    *--Annette Boyer, Colorado--;
> %INCLUDE SASCode(JobsProf) ;   *--Roy Williams, Massachusetts--;
> %INCLUDE SASCode(LangProf) ;   *--Annette Boyer, Colorado--;
> %INCLUDE SASCode(migrprof) ;   *--Jeff Wallace, Oklahoma--;
> %INCLUDE SASCode(Povprof) ;    *--Phyllis Smith, Amrut K., et al, Arkansas--;
> %INCLUDE SASCode(tranprof) ;   *--Jeff Wallace, Oklahoma--;
> %* That's a lot of %INCLUDE's! May add macro that builds the %INCLUDE list selectively
> based on &profiles value. It was in the 1990 STF3 package ;
  
  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' THEN PUT  #2 'Area Name: ' AreaName ;
     ELSE PUT #2 'Area: ' AreaName 'Geo. Component:' geocomp $geocomp. ;
  LENGTH TypeString $ 60 ;
< 
> * Minimal list of summary levels--John Blodgett's cnvtsf3 package has a much fuller
>   $SumLev. list, but the strings would first need to be abbreviated substantially. ;
  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)||'  CD: '||CD106 ;
<   IF (Urbanrur NE ' ')    THEN GeoString=TRIM(GeoString)||'  Urban/Rural: '||UrbanRur ;
>   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 ;
  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;
> / @1 credline ;
  RETURN;  *************end HeadFoot routine**************;
  RUN;
< *ODS ps close ;
< ods printer close;
<   %mend sdcpro3;
< 
> ODS ps close ;
> %PUT state=&stab geocomps=&geocomps profiles=&profiles pages: 1=&pages1 2=&pages2 A=&pagesA D=&pagesD E=&pagesE F=&pagesF H=&pagesH I=&pagesI J=&pagesJ L=&pagesL M=&pagesM P=&pagesP T=&pagesT ;
