Formats file outside program file

Typically, if a user wants to add formats to a file they are added as the data are read in. However, if a user anticipates using lots of formats in a data set and wants to be able to easily modify the formats file, it is easier to have a separate formats file.

The following is an example of what this file, formats.sas, would look like.

libname nepal '/usr/dawork/neidert/nepal';
options ls=80 ps = 60;
proc format fmtlib library=nepal cntlout=dsfmt;
value ffchck 1 = 'yes'
             . = 'not checked'
             .a = 'inap/skip'  ;
value ffeduc 11 = 'S.L.C or equiv'
             12 = 'I.A. or equiv'
             14 = 'B.A. or equiv'
             16 = 'M.A. or equiv'
             18 = 'Ph.D. or equiv'
             .a = 'inap/skip'
             .d = 'don''t know'
             . = 'no response given'
;
value ffagree 1 = 'agree'
             2 = 'somewhat agree'
             3 = 'disagree'
            .a = 'inap'
            .d = 'don''t know'
            .  = 'no response given'
;
run;
quit;

Typically, this file would be much larger. If the user wants to add another format to the file, say 'yesno,' the file would now look like this:

libname nepal '/usr/dawork/neidert/nepal';
options ls=80 ps = 60;
proc format fmtlib library=nepal cntlout=dsfmt;
value ffchck  1 = 'yes'
              . = 'not checked'
             .a = 'inap/skip'
;
value ffeduc 11 = 'S.L.C or equiv'
             12 = 'I.A. or equiv'
             14 = 'B.A. or equiv'
             16 = 'M.A. or equiv'
             18 = 'Ph.D. or equiv'
             .a = 'inap/skip'
             .d = 'don''t know'
             . = 'no response given'
;
value ffagree 1 = 'agree'
              2 = 'somewhat agree'
              3 = 'disagree'
             .a = 'inap'
             .d = 'don''t know'
             .  = 'no response given'
;
value yesno   1 = 'yes'
              0 = 'no'
             .a = 'inap'
             .d = 'don''t know'
             .  = 'no response given'
;
run;
quit;

To activate this new format:

sas formats.sas

This replaces the previous formats.sct01 file with a new format.sct01 file.


NEW PSC blog

Recent resources, events, news

New Publications

Knodel et al. "Gendered Housework in Vietnam." PSC Research Report.

Couper. Designing Effective Web Surveys

Next Brown Bag

Monday, Oct 13
Jamie Jones
"Fertility & Risk Aversion on Utah Frontier"


W A R N I N G

If you are reading this, it may be that you are using rather old web browsing software that does not support modern international Web technology standards. For a better experience of the Web and this site in particular, please upgrade your web browser software today. The following are good choices: Firefox 2; Opera 9; Safari 3.