/************* for 1980 Census Files ********************************* NOTE: You can copy this to a file directly from here, and use the program shown below as a sample, so that it need not be re-typed entirely. Depending on your browser, you can probably click 'File' then 'Save As' to save this into a usable file. ********************************************************************** Making Subsets of 1980 STF3A Census Data for Use in Packages Other than SAS or SPSS ---------------------------------------------------------------------- Some of the Census files are larger than 1 Gb, and as such, often cannot be moved to UNIX disk. This means that creating a text-only (ASCII) subset of the data may be helpful. SAS can be used for this purpose. When the data you want are in a SAS data set, a simple SAS PUT statement can output the data into "raw" (ascii) form to be read into whatever package you are going to use. A sample SAS program to read in a subset of Census variables from the STF3A file and output raw data is shown here. (This directory also contains a similar file for STF1A data.) For the example, we assume you are using seven Census variables, five from the first record and one from the third and one from the fifth. (Each "logical" record of the STF3A data is split into six physical records of 2016 bytes each. These are referred to in the Census documentation as "segments".) Since some Census variables are character variables, which result in completely blank spaces if missing, the output program specifies column beginning points using the @1, @7, @12 (etc.) pointers, so that the data 'line up' regardless of width or missing values. An example of the output follows the program. ***********************************************************************/ FILENAME RAW '~datastor/census/census1980/census80.stf3a'; DATA CENSUS; INFILE RAW LRECL=2016; INPUT FILEID $ 1-5 SUMRYLVL $ 10-11 FSTATUS $ 22 STATE $ 34-35 TRACT $ 50-55 / / T060_02 1272-1280 / / T106_01 535-543 / ; FILENAME SUBSET 'my.raw.census.subset'; DATA _NULL_; SET CENSUS; FILE SUBSET; PUT @1 FILEID @7 SUMRYLVL @12 FSTATUS @15 STATE @20 TRACT @30 T060_02 @40 T106_01 ; RUN; /********************************************************************* (NOTE that even if you are not reading any variables from the second, third, fifth and sixth physical records or segments, you still must have the slashes in the INPUT statement so that SAS knows there are six physical records per observation.) To use the above file for your own work, you need change only the INPUT statement and the PUT statement. For the INPUT statement, simply list the variables and column specifications (with the $ if you're reading an alphanumeric variable) from the Census code book for those variables you want to read. For the PUT statement, just list the same variable names (but no columns or $, unless you need to have the values lined up in columns) that you used in your INPUT statement. To run the program, type it into a UNIX file, then enter sas SAS will create the raw data file 'my.raw.census.subset' (or whatever you decide to call it). The contents of this file, as generated by the example above, will look like this (only the first ten observations are shown): STF3A 04 A 06 977290300 185309 STF3A 11 A 06 432999000 19121 STF3A 12 S 06 93986200 596 STF3A 13 A 06 93986200 596 STF3A 14 S 06 4271 4296500 0 STF3A 15 S 06 4271 1782800 0 STF3A 15 S 06 4271 1199100 0 STF3A 15 S 06 4271 219400 0 STF3A 15 S 06 4271 608300 0 STF3A 15 S 06 4271 486900 0 You can then use this raw file as input to the stat package of your choice. **************************************************************/