Home > Data Services > Catalog . Restricted Data . Census . ACS

Search Data Services

Meta Search
search across all the following databases:

Data Catalog
Data and documentation

KnowledgeBase
Common questions and answers.

Resources
Entire collection of data resources.


Latest Data News

RSS Feed icon

Lessons from North of the Border

Nerd Alert: Dictionary of Numbers

International Migration Statistics for the US

Open Data Executive Order

Measuring Marriage & Divorce among Same-Sex Couples

Reading in raw data with formats

Formats are useful for labeling output. It is easiest if one has the formats separate from the rest of the input program. This allows one to add additional formats to recoded variables at a later time.

The first file, called test.fmt reads in the labels for sex. The format is fsex.

libname test '/usr/work/lisan/shared/extract';
options ls=80 ps=60;
proc format fmtlib library=test cntlout=dsfmt;
value fsex 1 = 'male' 
           2 = 'female';
run;
quit;

To invoke this program:

\sas test.fmt 

If, you need to add more labels to my variables, edit the file, test.fmt, and then re-compile the program with \sas test.fmt.

The input file for reading the raw data and associating the data with the formats is as follows:

libname test '/usr/work/lisan/shared/extract';
libname library  '/usr/work/lisan/shared/extract';
data test.test;
infile '/usr/work/lisan/shared/extract/test.dat';
input
sex 1-1;
format sex fsex.;
proc freq;
   tables sex;
run;

Submit this program via the queue. The results will be an output file with labeled frequencies and a sas system file.