/******* STF3A Census Data Sample Program ******************************* This program reads all variables in the 1990 STF3A Census data into a SAS data set. NOTE that the STF3A data are stored in two separate files on the RCF, so this program is designed to run twice. This is done with a SAS Macro, so you will not have to modify anything in order to read both parts of the data. You may, however, want to make modifications to limit the number of variables read in, the type of observations you keep, etc. The final SAS data set that is created is called STF3ALL and is stored in the location specified in the LIBNAME statement. To read in all data into all variables (not recommended), use the program as is. To read in a subset, delete from the INPUT statement the line(s) containing the variables you don't want (or modify the KEEP statement provided at the top of the program). DO NOT delete the three slashes that represent the beginning of the 2nd, 3rd and 4th physical records. Your input statement MUST always have three slashes, regardless of which or how many variables you are reading. The variables in the "Identification Section" (first 300 bytes, sometimes called the GEO variables) have the following format: here are two examples: STUSAB $ 9- 10 LOGRECNU 19- 24 The variables in the "Table (Matrix) Section" have one of the following formats, depending on whether a single variable or multiple variables are being read in: when a single variable is being read: @ for example: @6871 H061A 9.0 when a group of variables are being read: @ (<1st variable - last variable>) () for example: @6880 (H062_01-H062_02) (15.0) Please note that this program is provided WITHOUT guarantee of its accuracy. This program was modeled after one distributed by the Computing Center (UC DATA) at the University of California, Berkeley. We acknowledge their work with thanks. /****************************************************************************/ OPTIONS NOCENTER LINESIZE=79; /* This LIBNAME statement directs SAS Data Sets to /tmp. Change this if you want them directed elsewhere. NOTE that if all variables and all observations are read, the resulting SAS data set will be enormous, so a very large /tmp space would be necessary. Subset if you can. */ LIBNAME CENSDATA '/tmp'; %MACRO STF3A90; %DO I=1 %TO 2; FILENAME STF3A90&i. "~datastor/census/census1990/census90.stf3a.ca.pt&i."; DATA CENSUS&i.; INFILE STF3A90&i. LRECL=7925; KEEP _ALL_; /***** INPUT PORTION of the program ***************************************** From here nearly to the end of this program is the INPUT portion. To include only variables of interest in your final SAS data set, delete the other variables (i.e., the ones you don't want) from this INPUT statement, or change the KEEP statement just above to list the variables you want to keep, e.g., KEEP STUSAB SUMLEV STATE CNTY P001; ****************************************************************************/ INPUT /* STF3A has 4 physical records per observation, total=31,700 bytes */ FILEID $ 1- 8 /* here begin the 'geographic info' variables */ STUSAB $ 9- 10 SUMLEV 11- 13 GEOCOMP 14- 15 CHARITER 16- 18 LOGRECNU 19- 24 LOGRECPN 25- 28 PARTREC 29- 32 ANRC $ 33- 34 AIANACE $ 35- 38 AIANAFP $ 39- 43 AIANACC $ 44- 45 ARTLI $ 46- 46 BLCK $ 47- 50 BLCKGR $ 51- 51 TRACTBNA 52- 57 /* tract with optional two-digit suffix */ TRACT4 52- 55 /* main tract number: first 4 numbers of TRACTBNA */ TRACT2 56- 57 /* suffix: last 2 numbers of TRACTBNA */ CONGDIS $ 58- 59 CONCITCE $ 60- 60 CONCITFP $ 61- 65 CONCITCC $ 66- 67 CONCITSC $ 68- 69 CMSA $ 70- 71 CNTY $ 72- 74 CNTYSC $ 75- 76 COUSUBCE $ 77- 79 COUSUBFP $ 80- 84 COUSUBCC $ 85- 86 COUSUBSC $ 87- 88 DIVIS $ 89- 89 EXTCITIN $ 90- 90 INTUC $ 91-105 MSACMSA $ 106-109 MSACMSAS $ 110-111 PLACECE $ 112-115 PLACEFP $ 116-120 PLACECC $ 121-122 PLACEDC $ 123-123 PLACESC $ 124-125 PMSA $ 126-129 REG $ 130-130 STATECE $ 131-132 STATEFP $ 133-134 URBANRUR $ 135-135 URBAREA $ 136-139 UASC $ 140-141 SAC1 $ 142-146 SAC2 $ 147-151 SAC3 $ 152-155 SAC4 $ 156-159 SAC5 $ 160-162 SAC6 $ 163-165 SAC7 $ 166-167 SAC8 $ 168-169 SAC9 $ 170-170 SAC10 $ 171-171 AREALAND $ 172-181 AREAWAT $ 182-191 ANPSADPI $ 192-257 FUNCSTAT $ 258-258 GCUNI $ 259-259 HU100 $ 260-268 INTPTLAT $ 269-277 INTPTLNG $ 278-287 PARTFLAG $ 288-288 PSADC $ 289-290 POP100 $ 291-299 SPFLAG $ 300-300 @301 P001 9.0 @310 P002 9.0 @319 P003 9.0 @328 P003A 9.1 /* note the decimal format */ @337 P004 9.0 @346 P005 9.0 @355 ( P006_01- P006_04 ) (9.0) @391 ( P007_01- P007_02 ) (9.0) @409 ( P008_01- P008_05 ) (9.0) @454 ( P009_01- P009_25 ) (9.0) @679 P010 9.0 @688 ( P011_01- P011_16 ) (9.0) @832 ( P012_01- P012_10 ) (9.0) @922 ( P013_01- P013_31 ) (9.0) @1201 ( P014_001-P014_310 ) (9.0) @3991 ( P015_01- P015_62 ) (9.0) @4549 ( P016_01- P016_07 ) (9.0) @4612 ( P017_01- P017_15 ) (9.0) @4747 ( P018_01- P018_12 ) (9.0) @4855 ( P019_01- P019_07 ) (9.0) @4918 ( P020_01- P020_35 ) (9.0) @5233 ( P021_01- P021_07 ) (9.0) @5296 ( P022_01- P022_06 ) (9.0) @5350 ( P023_01- P023_21 ) (9.0) @5539 ( P024_01- P024_14 ) (9.0) @5665 ( P025_01- P025_04 ) (9.0) @5701 ( P026_01- P026_07 ) (9.0) @5764 ( P027_01- P027_12 ) (9.0) @5872 ( P028_01- P028_30 ) (9.0) @6142 ( P029_01- P029_07 ) (9.0) @6205 ( P030_01- P030_33 ) (9.0) @6502 ( P031_01- P031_26 ) (9.0) @6736 ( P032_01- P032_04 ) (9.0) @6772 ( P033_01- P033_36 ) (9.0) @7096 ( P034_01- P034_36 ) (9.0) @7420 ( P035_01- P035_37 ) (9.0) @7753 ( P036_01- P036_10 ) (9.0) @7843 ( P037_01- P037_06 ) (9.0) @7897 ( P038_01- P038_03 ) (9.0) /* Phys. Record #2 resumes with P038_04*/ @7924 FILLER1 $2. /****************************************************************************/ /****************** End of Physical record # 1 *************************/ /****************************************************************************/ / /* this slash (and those found below for the other physical records) must remain in the INPUT program, even if all subsequent variables are deleted. */ /****************************************************************************/ /************************** Physical record # 2 *************************/ /****************************************************************************/ /* the first 300 columns of this record have the same variables and information as the first 300 columns of the first physical record so we do not read them again here. NOTE that since this is a new physical record, column numbering starts over (i.e., it does not continue from 7925, which was the end of the first physical record). The Census documentation calls this the second "segment" in the codebook. */ @301 ( P038_04- P038_08 ) (9.0) @346 ( P039_01- P039_08 ) (9.0) @418 ( P040_01- P040_10 ) (9.0) @508 ( P041_01- P041_06 ) (9.0) @562 ( P042_01- P042_09 ) (9.0) @643 ( P043_01- P043_10 ) (9.0) @733 ( P044_01- P044_12 ) (9.0) @841 ( P045_01- P045_03 ) (9.0) @868 ( P046_01- P046_03 ) (9.0) @895 ( P047_01- P047_08 ) (9.0) @967 ( P048_01- P048_03 ) (9.0) @994 ( P049_01- P049_13 ) (9.0) @1111 ( P050_01- P050_13 ) (9.0) @1228 P051 9.0 @1237 ( P052_01- P052_15 ) (9.0) @1372 ( P053_01- P053_08 ) (9.0) @1444 ( P054_01- P054_07 ) (9.0) @1507 ( P055_01- P055_20 ) (9.0) @1687 ( P056_01- P056_04 ) (9.0) @1723 ( P057_01- P057_07 ) (9.0) @1786 ( P058_01- P058_35 ) (9.0) @2101 ( P059_01- P059_07 ) (9.0) @2164 ( P060_01- P060_07 ) (9.0) @2227 ( P061_01- P061_13 ) (9.0) @2344 ( P062_01- P062_65 ) (9.0) @2929 ( P063_01- P063_13 ) (9.0) @3046 ( P064_01- P064_12 ) (9.0) @3154 ( P065_01- P065_13 ) (9.0) @3271 ( P066_01- P066_28 ) (9.0) @3523 ( P067_01- P067_24 ) (9.0) @3739 ( P068_01- P068_16 ) (9.0) @3883 ( P069_01- P069_24 ) (9.0) @4099 ( P070_01- P070_08 ) (9.0) @4171 ( P071_01- P071_40 ) (9.0) @4531 ( P072_01- P072_08 ) (9.0) @4603 ( P073_01- P073_12 ) (9.0) @4711 ( P074_01- P074_16 ) (9.0) @4855 ( P075_01- P075_04 ) (9.0) @4891 ( P076_01- P076_38 ) (9.0) @5233 ( P077_01- P077_17 ) (9.0) @5386 ( P078_01- P078_13 ) (9.0) @5503 ( P079_01- P079_07 ) (9.0) @5566 ( P080_01- P080_25 ) (9.0) @5791 P080A 9.0 @5800 ( P081_01- P081_02 )(15.0) @5830 ( P082_01- P082_45 ) (9.0) @6235 ( P083_01- P083_09 ) (9.0) @6316 ( P084_01- P084_05 )(15.0) @6391 P085 15.0 @6406 ( P086_01- P086_63 ) (9.0) @6973 ( P087_001-P087_105 ) (9.0)/* Phys. Record #3 resumes with P087_106 */ @7918 FILLER2 $8. /****************************************************************************/ /****************** End of Physical record # 2 *************************/ /****************************************************************************/ / /* this slash (and those found above and below for the other physical records) must remain in the INPUT program, even if all subsequent variables are deleted. */ /****************************************************************************/ /************************** Physical record # 3 *************************/ /****************************************************************************/ /* the first 300 columns of this record have the same variables and information as the first 300 columns of the first physical record so we do not read them again here. NOTE that since this is a new physical record, column numbering starts over (i.e., it does not continue above 7925, which was the end of the first physical record). The Census documentation calls this the third "segment" in the codebook. */ @ 301 ( P087_106-P087_315 ) (9.0) @2191 ( P088_01- P088_63 ) (9.0) @2758 ( P089_01- P089_02 ) (9.0) @2776 ( P090_01- P090_02 ) (9.0) @2794 ( P091_01- P091_02 ) (9.0) @2812 ( P092_01- P092_02 ) (9.0) @2830 ( P093_01- P093_02 ) (9.0) @2848 ( P094_01- P094_02 ) (9.0) @2866 ( P095_01- P095_02 ) (9.0) @2884 ( P096_01- P096_02 ) (9.0) @2902 ( P097_01- P097_02 ) (9.0) @2920 P098 15.0 @2935 P099 15.0 @2950 P100 15.0 @2965 P101 15.0 @2980 P102 15.0 @2995 P103 15.0 @3010 P104 15.0 @3025 P105 15.0 @3040 ( P106_01- P106_06 ) (9.0) @3094 ( P107_01- P107_25 ) (9.0) @3319 P107A 9.0 @3328 ( P108_01- P108_02 )(15.0) @3358 ( P109_01- P109_06 )(15.0) @3448 ( P110_01- P110_25 ) (9.0) @3673 P110A 9.0 @3682 ( P111_01- P111_02 )(15.0) @3712 ( P112_01- P112_04 ) (9.0) @3748 ( P113_01- P113_04 )(15.0) @3808 ( P114_01- P114_04 )(15.0) @3868 P114A 9.0 @3877 ( P114B_01-P114B_04) ( 9.0) @3913 ( P115_01- P115_05 )(15.0) @3988 ( P115A_01-P115A_05 )( 9.0) @4033 P116 15.0 @4048 P116A 9.0 @4057 ( P117_01- P117_24 ) (9.0) @4273 ( P118_01- P118_28 ) (9.0) @4525 ( P119_01- P119_70 ) (9.0) @5155 ( P120_01- P120_14 ) (9.0) @5281 ( P121_01- P121_09 ) (9.0) @5362 ( P122_01- P122_54 ) (9.0) @5848 ( P123_01- P123_24 ) (9.0) @6064 ( P124_001-P124_120 ) (9.0) @7144 ( P125_01- P125_24 ) (9.0) @7360 ( P126_01- P126_18 ) (9.0) @7522 ( P127_01- P127_30 ) (9.0) @7792 ( P128_01- P128_03 ) (9.0) @7819 ( P129_01- P129_02 ) (9.0) @7837 ( P130_01- P130_03 ) (9.0) @7864 ( P131_01- P131_03 ) (9.0) @7891 ( P132_01- P132_03 ) (9.0) @7918 FILLER3 $8. /****************************************************************************/ /******************* End of Physical record # 3 *************************/ /****************************************************************************/ / /* this slash (and those found above and below for the other physical records) must remain in the INPUT program, even if all subsequent variables are deleted. */ /****************************************************************************/ /************************** Physical record # 4 *************************/ /****************************************************************************/ /* the first 300 columns of this record have the same variables and information as the first 300 columns of the first physical record so we do not read them again here. NOTE that since this is a new physical record, column numbering starts over (i.e., it does not continue above 7925, which was the end of the first physical record). The Census documentation calls this the fourth "segment" in the codebook. */ @301 (P133_01- P133_03) (9.0) @328 (P134_01- P134_03) (9.0) @355 (P135_01- P135_02) (9.0) @373 (P136_01- P136_03) (9.0) @400 (P137_01- P137_03) (9.0) @427 (P138_01- P138_03) (9.0) @454 (P139_01- P139_03) (9.0) @481 (P140_01- P140_03) (9.0) @508 (P141_01- P141_03) (9.0) @535 (P142_01- P142_03) (9.0) @562 (P143_01- P143_03) (9.0) @589 (P144_01- P144_05) (9.0) @634 (P145_01- P145_03) (9.0) @661 (P146_01- P146_04) (9.0) @697 (P147_01- P147_04) (9.0) @733 (P148_01- P148_03) (9.0) @760 (P149_01- P149_03) (9.0) @787 (P150_01- P150_03) (9.0) @814 (P151_01- P151_03) (9.0) @841 (P152_01- P152_03) (9.0) @868 (P153_01- P153_03) (9.0) @895 (P154_01- P154_04) (9.0) @931 (P155_01- P155_03) (9.0) @958 (P156_01- P156_04) (9.0) @994 (P157_01- P157_04) (9.0) @1030 (P158_01- P158_04) (9.0) @1066 (P159_01- P159_03) (9.0) @1093 (P160_01- P160_03) (9.0) @1120 (P161_01- P161_04) (9.0) @1156 (P162_01- P162_04) (9.0) @1192 (P163_01- P163_03) (9.0) @1219 (P164_01- P164_03) (9.0) @1246 (P165_01- P165_03) (9.0) @1273 (P166_01- P166_03) (9.0) @1300 (P167_01- P167_02) (9.0) @1318 (P168_01- P168_02) (9.0) @1336 (P169_01- P169_02) (9.0) @1354 (P170_01- P170_03) (9.0) /*** Housing variables now: ***/ @1381 H001 9.0 @1390 H002 9.0 @1399 H003 9.0 @1408 H003A 9.1 /* decimal! */ @1417 (H004_01- H004_02) (9.0) @1435 (H005_01- H005_04) (9.0) @1471 (H006_01- H006_08) (9.0) @1543 (H007_01- H007_06) (9.0) @1597 (H008_01- H008_02) (9.0) @1615 (H009_01- H009_05) (9.0) @1660 (H010_01- H010_10) (9.0) @1750 (H011_01- H011_10) (9.0) @1840 (H012_01- H012_10) (9.0) @1930 (H013_01- H013_14) (9.0) @2056 (H014_01- H014_10) (9.0) @2146 (H015_01- H015_02) (9.0) @2164 (H016_01- H016_09) (9.0) @2245 H017 9.0 @2254 (H018_01- H018_14) (9.0) @2380 (H019_01- H019_02) (9.0) @2398 (H020_01- H020_10) (9.0) @2488 (H021_01- H021_10) (9.0) @2578 (H022_01- H022_20) (9.0) @2758 (H023_01- H023_04) (9.0) @2794 (H024_01- H024_03) (9.0) @2821 (H025_01- H025_08) (9.0) @2893 H025A 9.0 @2902 (H026_01- H026_08) (9.0) @2974 (H027_01- H027_16) (9.0) @3118 (H028_01- H028_06) (9.0) @3172 (H029_01- H029_12) (9.0) @3280 (H030_01- H030_09) (9.0) @3361 (H031_01- H031_06) (9.0) @3415 (H032_01- H032_06) (9.0) @3469 (H033_01- H033_12) (9.0) @3577 (H034_01- H034_28) (9.0) @3829 (H035_01- H035_04) (9.0) @3865 (H036_01- H036_08) (9.0) @3937 (H037_01- H037_12) (9.0) @4045 (H038_01- H038_02) (9.0) @4063 (H039_01- H039_10) (9.0) @4153 (H040_01- H040_02) (9.0) @4171 (H041_01- H041_04) (9.0) @4207 (H042_01- H042_02) (9.0) @4225 (H043_01- H043_17) (9.0) @4378 H043A 9.0 @4387 H044 15.0 @4402 (H045_01- H045_35) (9.0) @4717 (H046_01- H046_14) (9.0) @4843 (H047_01- H047_02) (9.0) @4861 (H048_01- H048_02) (15.0) @4891 (H049_01- H049_02) (9.0) @4909 (H050_01- H050_30) (9.0) @5179 H050A 9.1 /* decimal ! */ @5188 (H051_01- H051_12) (9.0) @5296 (H052_01- H052_21) (9.0) @5485 (H052A_01-H052A_02) (9.0) @5503 (H053_01- H053_02) (15.0) @5533 (H054_01- H054_55) (9.0) @6028 (H055_01- H055_11) (9.0) @6127 (H056_01- H056_02) (15.0) @6157 (H057_01- H057_02) (15.0) @6187 (H058_01- H058_12) (9.0) @6295 (H058A_01-H058A_02) (9.1) /* decimal ! */ @6313 (H059_01- H059_30) (9.0) @6583 (H060_01- H060_12) (9.0) @6691 (H061_01- H061_20) (9.0) @6871 H061A 9.0 @6880 (H062_01- H062_02) (15.0) @6910 (H063_01- H063_03) (15.0) @6955 (H064_01- H064_02) (9.0) @6973 (H065_01- H065_02) (9.0) @6991 (H066_01- H066_10) (9.0) @7081 (H067_01- H067_02) (9.0) @7099 (H068_01- H068_04) (9.0) @7135 (H069_01- H069_12) (9.0) @7243 (H070_01- H070_20) (9.0) @7423 (H071_01- H071_08) (9.0) @7495 (H072_01- H072_02) (9.0) @7513 (H073_01- H073_02) (9.0) @7531 (H074_01- H074_02) (9.0) @7549 (H075_01- H075_02) (9.0) @7567 (H076_01- H076_02) (9.0) @7585 (H077_01- H077_02) (9.0) @7603 (H078_01- H078_02) (9.0) @7621 (H079_01- H079_02) (9.0) @7639 (H080_01- H080_02) (9.0) @7657 (H081_01- H081_02) (9.0) @7675 (H082_01- H082_02) (9.0) @7693 (H083_01- H083_02) (9.0) @7711 (H084_01- H084_02) (9.0) @7729 (H085_01- H085_02) (9.0) @7747 (H086_01- H086_02) (9.0) @7765 (H087_01- H087_02) (9.0) @7783 (H088_01- H088_02) (9.0) @7801 (H089_01- H089_02) (9.0) @7819 (H090_01- H090_02) (9.0) @7837 (H091_01- H091_02) (9.0) @7855 (H092_01- H092_04) (9.0) @7891 FILLER4 $35. ; /* the famous semicolon. This marks the end of the INPUT statement */ %END; %MEND STF3A90; %STF3A90 DATA CENSDATA.STF3ALL; SET CENSUS1 CENSUS2; IF TRACT2 NE ' ' THEN TRACTNUM=TRIM(LEFT(TRACT4))||'.'|| TRIM(LEFT(TRACT2)); ELSE TRACTNUM=TRIM(LEFT(TRACT4)); RUN;