%sdcpro3(stab=mo,sumlev=040,profiles=t)
OPTIONS LINESIZE=149 PAGESIZE=64 PAGENO=1 NODATE NONUMBER ORIENTATION=LANDSCAPE ;
FILENAME Codelib "/pub/data/sf32000/sdcprofiles"; *<== probably edit only once ;
LIBNAME sf3 "/pub/data/sf32000/temp" 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 ;
ODS ps file="/pub/webrepts/sdcprofiles3/mo/040t.ps" pdfmark style=SF3style ;
DATA _null_ ;
MERGE sf3.moph sf3.mophct sf3.mophctR ;
BY LogRecNo ;
where SumLev="040";
if index("00",geocomp);
FILE PRINT LINESIZE=149 PAGESIZE=65 N=PAGESIZE NOTITLES;
LENGTH _PAGES $11 profiles $13;
RETAIN profiles "T" ;
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 (1=0) THEN RunPage=0 ;
LENGTH Underline DoubleLine SingleLine $149 ;
RETAIN Underline DoubleLine SingleLine VBAR '|' PLUS '+' _first 1;
IF _first THEN DO;
  RunDate="26AUG02";
  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 ;
ProfID='Transport';
_PAGES="";
LINK tranprof;
IF _ERROR_ THEN LINK err;
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;
/* (tranprof included here) */ *--Jeff Wallace, Oklahoma--;
HeadFoot: 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 ;
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 ;
* 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 "Profile prepared by the Missouri Census Data Center (MCDC), http://mcdc.missouri.edu";
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 / @15 "Report generated on 26AUG02 at 14:59";
RETURN;
*************end HeadFoot routine**************;
RUN;
ODS ps close ;
