1(STFRGENB) 0STFRGENB: USING THE SCADS REPORT GENERATOR ------------------------------------------ The "display" portion of the SAS Census Access and Display System is embodied in the STFRGENB report generating macro. This macro, written in the "new" (preprocessor) SAS macro language, allows the user to generate reports which consist of complete STF table displays. It allows the user to handle requests such as: -"Display all tables from STF3 for all tracts in the SMSA" -"Print a report showing all tables related to income and poverty for all counties where the median household income is less than $15,000". As we describe the parameters that can be specified to the macro you should see what its capabilities are. What you have to remember is that basically STFRGENB is simply an assembler of previously-written coding modules called "display macros". These macros are supplied as part of the SCADS package. They are stored in the SCADS system macro library. There is a set of display macros for each STF, and each of these sets is one member of the macro library. (For STF's 2 and 4 there are multiple sets of display macros corresponding to the diff- erent record types (a vs. b) or data type (p vs h on STF4).) Within each of these members there is a series of (old-style) SAS macros--one for each table on the STF. A rigorous macro-naming (as well as member-naming) convention is used to allow STFRGENB to generate the appropriate invocations of these program modules. Most users of the system should find that the display macros as supplied will be sufficient. However, you should keep in mind that since they are distributed in easy to read source code, it should be easy for someone familiar with the SAS language to modify them in order to "customize" (within limits) how the data is to be edited, collapsed, reformatted and displayed. 0 Using STFRGENB involves invoking the SAS system in the usual way (e.g. in OS batch by coding "// EXEC SAS") and supplying usually only two addtional file declarations (DD statements, ALLOCs, FILEDEFs). You must always define the SCADS sytem macro library and associate it with the file name MACLIB. In batch you would code (after your "EXEC SAS" statement): //MACLIB DD DSN=<++maclib>,DISP=SHR where <++maclib> is the DSN assigned to the SCADS macro library at your installation. You will also need to code a DD statement (or its equivalent) for each STF dataset from which you need to extract and print data. The default file name (DDname) used by STFRGENB is "STFIN". You will need to code a DD statement similar to: //STFIN DD DSN=<++CATNAME>.STF3A.IL17.L2,DISP=(SHR,PASS) where <++CATNAME> is the catalog structure used to name your SCADS datasets and where we have assumed your installation is following the suggested guidelines for naming SCADS data libraries. The sample shows a DD statement for an STF3 level 2 data library for the state of Illinois. You need only 1 DD statement to allow access to any or all of the datasets on this data library (STATES, COUNTIES, TRACTS, etc.) "DISP=(SHR,PASS)" tells the system to share the dataset (impossible but harmless if data is on tape), while the PASS spec tells the system to keep the tape mounted upon closing, which is necessary if you want to access multiple datasets on the library. 0 STFRGENB generates its reports on the PRINT file. This can be FT12F001 (by default) or you can use PROC PRINTTO to direct it to a different print file. If you need to generate your report on a file other than the standard print file allowed for in your SAS JCL PROC (TSO CLIST, etc.), you will need to provide the appropriate DD statement (ALLOC, etc.). If this is Greek to you then you prob- ably don't need to know it. Check with your local systems person for assistance in directing your report to a specific printer or print file, or in modifying the characteristics of the print file. 0 Assuming you have taken care of getting all the appropriate files allocated, the first thing you need to do when you begin coding your SAS statements is to include the STFRGENB code. You can do this with the statement %INCLUDE MACLIB(STFRGENB); . (You might wish to add the option "/NOSOURCE2" on this statement to suppress the rather long source listing of the macro.) At this point you could generate a report displaying all the tables from your STF3A COUNTIES dataset by coding something as simple as: TITLE ALL STF3 TABLES FOR ALL COUNTIES IN ILLINOIS; %STFRGENB(STF=3,GEOCODE=COUNTY,TABLES=ALL); . If your shop is like ours, better than 50% of your invocations of STFRGENB will be about as simple as this. Many users will have little or no use for many of the options and parameters that have been built into STFRGENB to allow you to have more control over what data will appear in your reports and how it will fill the page. If you feel you are only going to be a "casual" user of the report-generator using mostly default options then you may wish to skim very lightly over these detailed parameter explanations. 0 This HELP module is intended to provide a more in-depth description of the STFRGENB parms. Once you get the general hang of how it works you should note that these parms are described in a much more compact format in comment statements within the STFRGENB source code (right at the beginning, before the hairy stuff starts.) You may find it faster and easier to simply keep a listing of these comments handy (or, if you are using an interactive system, you can always browse the macro library member), rather than to list or consult this relatively windy explanation. 0 The syntax for invoking a SAS macro is very simple. You just code the name of the macro, immediately preceded by a % symbol. You follow this with a variable number of "parameter specifications" (parmspecs), enclosed in parentheses. Each of these parmspecs must be separated from its predecessor by a comma, and must be in the form =, where is the parameter-name as defined in the macro and as used in this documentation; and is a character string value to be associated with the parameter. Generally speaking strings should not contain special characters such as commas, percent symbols or quote marks. Blanks are usually OK. Of course, what really determines what values are "OK" for a parmval is the specific SAS code that tries to interpret the value in order to determine what you want to have done (or not done.) If you misspell a parameter name SAS will put a message on your log (or your terminal) indicating that the parameter name is not defined in the macro. If you forget to separate parmspecs with commas it can get more confusing since SAS then interprets the following parmspec as part of the value being assigned to the previous parameter. For example, if you code STFRGENB(STF=3 GEOCODE=TRACTS TABLES=1-10); (where the delimiting commas between the 1st and 2nd and the 2nd and 3rd parmspecs have been left out), SAS will assume that all the char- acters following "STF=" until the right parenthesis are all the value that you wish to assign to the STF parm. This is because, like most computer programs, it lacks common sense. You and I can see that this is silly, but the macro parser is blind to anything but commas or end- ing right parentheses when it looks for parmspec "delimiters". You have to play by its rules. Don't fight it--remember to put in the commas, and don't expect a message telling you that you forgot your commas if you don't. 0 You may have noticed the semicolon (;) coded at the end of the sample invocation above. This is not actually required to delimit a new-style macro invocation but it doesn't hurt and its better to be in the habit of ending all SAS statements the same way. It also makes it easier to "comment out" macro invocations by simply changing the leading % symbol to an asterisk (*). 0 So much for general rules about macros. Now lets look at the specific parameters recognized by STFRGENB and discuss what kinds of parameter values ('s) make sense and what effect they will have on your report. 0 Keep in mind that there are several different kinds of errors you can making using STFRGENB, or any new-style macro. You can make a syntax error that gets caught and diagnosed, or one that confuses (like forgetting the commas.) Or you can fail to specify a required parameter or specify a value that has no meaning or that is inconsist- ent with other parameters; this will usually cause the macro (if it is carefully written) to inform you of the problem and to halt execution. Remember that a macro like STFRGENB is actually a SAS code generator. It does not directly execute your request--it just looks at your request and converts it into SAS instructions which (if all goes well) are passed on to the regular SAS compiler. There is always the possi- bility that the code that is passed to SAS will have a problem. If this occurs, the problem is usually with the person who wrote the macro, not with the person who invoked it. (This does not apply to code supplied via "user-exit" macros, described below.) A third level at which things can go bad is at execution. At this point, STFRGENB has hopefully performed its duty of generating the SAS code, and the SAS compiler has successfully interpreted that code and begun to exectute. These problems usually have to do with bad data or missing data files, misnamed or lost variables, etc. It could be caused by asking to print tables for BLKGRPS from an STF2 file (the dataset does not exist--you will get a SAS 200--DATA SET NOT FOUND error message. Maybe the problem is in your JCL--you meant to print from an STF3 file, but your STFIN DD statement inadvertently references an STF2 file instead. 0 There is a fourth level where your request may fail. These are often the worst disasters. These are the cases where everything goes fine, and you get your 2,000 page report of all the tables for all the census tracts in New Hampshire, and then realize that what your user really asked for was all the tracts in Vermont. 0 STFRGENB has only 3 required parameters for most files. These three will be described first. Failing to specify a value for one of these parameters will result in a message reminding you that they are required, and no code will be generated. 0 The STF parameter specifies which Summary Tape File or 1970 Count file you wish to access. Recognized values are 1,2,3,4,C4, and C5. You may precede any of the single-digit values with "STF". C4 and C5 are used to indicate 1970 4th and 5th count files, respectively. (Don't use C4 yet--its not ready.) Do not specify a file suffix--it is irrelevant: STF1A and STF1B are all the same to this macro. Our experience has been that this is the parm that people most often for- get to code--they think the program will be clever enough to figure out which file it is from the data. But they shouldn't think that. We like to always code this parm first so we won't forget it. As with all other parm values that may contain alpha data, STFRGENB does an UPCASE on the values if invoked in the foreground (interactively); so you need not worry about up-casing the "c" in c5. 0 The next required parameter looked for by STFRGENB is GEOCODE. The value of this parm is the mnemonic name associated with the level of geography being reported. It is usually used to imply the value of the parm SETNAME (by simply appending an 'S' to the value of GEO- CODE; if GEOCODE=TRACT then SETNAME gets assigned a value of TRACTS.) There is an assumption here that you will be accessing standard SCADS level 2 data libraries which adhere to these naming conventions. You can specify the name of a level 1 dataset for SETNAME, or course, and use a value of GEOCODE equal to the lowest level of geography available on the dataset (that you want to print--you can always pre- select based on SUMRYLVL.) If you have created your own non-standard level 2 dataset that summarizes data for local WARDS (for example) then you should specify GEOCODE=WARD, and STFRGENB will imply that SETNAME=WARDS (it checks to see if SETNAME is specified, and if not, assigns a value by appending 'S' to GEOCODE.) See also the explana- tion of AUXGEOS below. 0 The last required parm (for all but STF2 and STF4) is TABLES. As its name suggests, it is used to tell the macro just which tables from the summary tape file are to be displayed. The value specified can be the word "ALL" (omit the quotes), or a list of "table specs". A table spec is a single numeric value (representing the number of a table that you wish to see printed), or can be a numeric interval such as 11-34 (which requests the printing of all tables from 11 to 34 inclusive.) Elements of the list must be separated by 1 or more blanks. So you could code TABLES=1 3 9 11 34 62 or, TABLES=68-74 112-118 12 . Table numbers do not need to be specified in ascending order, but the order in which they are specified is the order in which they will be displayed, and it is usually easier to find things when printed in table number order. The user must be careful not to specify duplicates or overlapping intervals as these will result in redundant displays. What STFRGENB does with this parm is to simply parse it and generate the corresponding display macro references. Thus, normally it would be an error to request a table number greater than 150 when STF=3. However, some shops may find it useful to define their own "tables" for display purposes, by adding more display macros to the SCADS macro library. There is no rule that says that a macro named _F83T151 has to reference a table 151 on STF3 (it is merely a convention.) 0 The RECTYPE parm is required for accessing STF2 and STF4. Both of these files have multiple sets of tables and hence multiple sets of display macros. The value specified must be either A or B. This parm is ignored for all other files (STF's). 0 The PH parm is only relevant for STF4 files, in which case it is required. The value must be either P or H, to tell the program whether you want to access a file of Population tables or Housing tables, respectively. 0 The DDNAME parm assumes the default value of STFIN if you do not specify it. Thus when dealing with only one file (data library) in a setup you can code the DD statement or allocate the file to this file name and not have to code this parm. When processing multiple files in one run, however, it will be necessary to give them unique file names and to use this parm to specify which one you want to access for the table display report. 0 SETNAME is used for the second level of the SAS dataset name. In- otherwords, STFRGENB is going to generate a SAS SET statement of the form SET .; . In most cases, the value of this parm can be implied from the value of the required parm GEOCODE (see above.) If specified, it must be a valid SAS name and, of course, the dataset must be found on the data library referenced by . 0 AUXGEOS is used to supply STFRGENB with a list of auxillary geo- codes that are to be printed out to help identify the geographic area being summarized in the table displays. For example, when doing MCD level displays it is appropriate to specify the STATE and COUNTY variable values as well as the value of MCD in order to identify which particular MCD is being summarized. Of course, if the report is titled "Selected Tables for All Townships in St. Charles County" then this could be viewed as redundant. You might want to specify AUXGEOS=" " to indicate that you do not want any auxillary geocodes listed. If you use a standard value of GEOCODE (any of COUNTY, MCD, PLACE, TRACT, ED, BLKGRP, BLOCK or CONDIST) then an appropriate list of qualifying geographic codes will be automatically generated for you. If you use STFRGENB to print a level 1 dataset with multiple summary levels then you should be sure to include SUMRYLVL in your AUXGEOS list. 0 Unless otherwise specified STFRGENB will always print the value of the AREANAME variable found on all STF files as part of the identify- ing data preceding the table displays. If you want to suppress this for some reason then you must code the parmspec NONAME=1 (or NONAMES=1). 0 The BREAKOPT parm is used to specify what you want to happen when the program begins printing a new set of tables (for the next geo- graphic area.) The default value of this parm is C, and signals the program to start a new column for each geocode. (STFRGENB normally displays tables in multi-column "phonebook" style to save paper.) If you specify a value of P then the program will always go to the top of a new page for each geocode. The only other valid values for BREAKOPT are T and N, both of which instruct the program to simply stay where it is, print the new geographic labels and continue printing tables in the same column on the same page. This is generally not to be recommended unless you are printing a very small number of tables for a relatively large number of areas and are concerned about keeping you paper usage down. 0 The COLS, LNSZ and PGSZ parameters are used together to tell STFRGENB how you want the tables laid out on the printed page. The default values are COLS=3 (says you want 3 columns or "repeated images" across the page); LNSZ=132 (says your printer has 132 char- acter positions to be used for the report); and PGSZ=60 (says to print 60 vertical lines (max) per page. When overriding you need to know that each "repeated image" requires 44 characters. If 44* is larger than LNSZ STFRGENB will inform you of the impossibility of your request. You should avoid values of LNSZ less than 64 (SAS won't accept them), and of course you need to supply values that accurately describe your print file setup. Changing PGSZ requires than you know how to specify the LINECT IBM system parameter. Be careful. 0 We have saved the most interesting parameter for last. SLCTEDIT is what we refer to as a "user exit macro". Since we plan to make use of this concept in a number of application macros in our system we have provided a separate module in this User's Guide (member USEREXIT) to describe the concept. It is really not all that complicated but it does require you to have some understanding of the SAS preprocessor macro language. You may wish to view the USEREXIT module before continuing here. The macro specified via SLCTEDIT is invoked immediately after the generated SET statement. You can use it to filter observations, to edit table items (caution: garbage edit, garbage out), or even to do exotic things like printing report index files. It is most commonly used to do geographic or data-based subsetting. A simple example of using such a macro follows: %MACRO FILTER; IF COUNTY='510'; *-SELECT ON CITY OF ST. LOUIS-*; %MEND FILTER; %STFRGENB(STF=1,GEOCODE=TRACT,TABLES=ALL,SLCTEDIT=FILTER); 0 The MACSIN parm is one that should be rarely used. Normally STFRGENB checks to see if has been previously called with the same STF value in order to avoid generating the %INCLUDE statement that brings in the table display macros. There are times, however, especially when debugging a new macro or small new subset, that you would like to tell the program not to include that enormous collection of code either because its already been included or because you've already entered or included a temporary alternative. For whatever reason, if you specify MACSIN=1 then the %INCLUDE statement will not be generated. Do not do it unless you understand everything you have just read. 0 There are several sample job setups included in the job library on the SCADS installation tape. *<== You might want to ask the SCADS installation person at your site for a listing of those setups, or to have them move the setup into this HELP library so you can browse it. 0 One last word of caution: be careful when just starting out. It is fairly easy to let a report get away from you. Remember that printing all 150 STF3 tables for a single geographic area takes about 19 pages in 3-column 60-lines-per-page format. Printing all the tables for all the tracts (or block groups) in a state or SMSA can generate an awful lot of paper. It is always useful to do trial runs to make sure that the format is just to your liking before letting the whole thing run. SAS makes such trial runs easy with system options like OBS and PAGES. We strongly recommend that you take advantage of these features.