## Trying to understand how to use Proc Format

Solved
Occasional Contributor
Posts: 12

# Trying to understand how to use Proc Format

Hi,

I'm reading my data and then trying to use Proc Format.  When I use Proc Print the initial values are not formatted.  After reading some explanations I'm not sure why and need a bit of help.  Thank you.

data mydata;
INFILE mysource dlm=',' missover;
input Site : \$1.
Pt : \$2.
Sex
Race
Dosedate : mmddyy10.
Height
Weight
Result1
Result2
Result3;

run;

proc format;
value Sex
1 = 'Female'
2 = 'Male';
value Race
1 = 'Asian'
2 = 'Black'
3 = 'Caucasian'
4 = 'other';

run;

proc print data=mydata;

run;

Accepted Solutions
Solution
‎07-14-2016 12:49 PM
Super User
Posts: 23,724

## Re: Trying to understand how to use Proc Format

You created a format, you never applied it.

``````Proc print data=mydata;
Format sex sex. Race race.;
Run;``````

This would only apply to the proc print however. You may want to change the order, put the proc format before the data import step and add the format statement to your data step.

All Replies
Regular Contributor
Posts: 215

## Re: Trying to understand how to use Proc Format

You'll want to call PROC FORMAT to create the formats before the data step. Then use them like other formats (Race Race., for example; like you might call Date monyy7.) in the data step.

Occasional Contributor
Posts: 12

## Re: Trying to understand how to use Proc Format

Thanks... please see my next commet to Reeza.

Solution
‎07-14-2016 12:49 PM
Super User
Posts: 23,724

## Re: Trying to understand how to use Proc Format

You created a format, you never applied it.

``````Proc print data=mydata;
Format sex sex. Race race.;
Run;``````

This would only apply to the proc print however. You may want to change the order, put the proc format before the data import step and add the format statement to your data step.

Occasional Contributor
Posts: 12

## Re: Trying to understand how to use Proc Format

Hi,

I moved the proc format to the top before the data step and ran the proc print using the format statement as suggested and to keep it simple for now... but it doesn't appear to affect the values.

Thank you.

Occasional Contributor
Posts: 12

## Re: Trying to understand how to use Proc Format

I noticed these notes in the log if it matters:

30 proc format;
31 value Sex
32 1 = 'Female'
33 2 = 'Male';
NOTE: Format SEX is already on the library WORK.FORMATS.
NOTE: Format SEX has been output.
34 value Race
35 1 = 'Asian'
36 2 = 'Black'
37 3 = 'Caucasian'
38 4 = 'other';
NOTE: Format RACE is already on the library WORK.FORMATS.
NOTE: Format RACE has been output.

Occasional Contributor
Posts: 12