search across all the following databases:
Data and documentation
Common questions and answers.
Entire collection of data resources.
SAS can accommodate repeated formats so that the user does not have to type in the same formats over and over. This is particularly useful with summary file data from the Census Bureau. The format of tables in STF files is almost always 9 characters per cell and a table might have 256 cells.
The following is an example of a program that pulls off a 5 cell table from a 1990 STF file:
filename stf pipe 'zcat /usr/data/public/us/government/stf/1990/3c/1990.Z'; data city; infile stf lrecl=7925; input sumlev 11-13 geocomp 14-15 @106 msa $4. @133 state $2. @409 (race1-race5) (9.) #3 median 3319-3327 #4; data cityx; set city; if sumlev ne 300 then delete; if geocomp ne 0 then delete; total = race1 + race2 + race3 + race4 + race5; black = (race2/total)*100; data out; set cityx; file counts; put @1 state $2. @4 msa $4. @9 (race1-race5) (10.); run;
The more tedious way to write this program is:
Lines 1 to 5 remain the same. Line 6 changes to: @409 race1 $9. @418 race2 $9. @427 race3 $9. @436 race4 $9. @445 race5 $9. #3 median 3319-3327 #4;