Reputation: 435
I wonder what does the IQ.
on the row of FORMAT (second to the last row) does in this piece of codes? Does it mean a termination of variable name? Or does it mean a transformation to integer? Or something else? Thank you!
The dataset is called IQ, and it contains only one numerical variable called IQ. These numbers appear to be integers.
PROC FORMAT;
VALUE IQ
75 - <85 = '75 <= IQ score < 85'
85 - <95 = '85 <= IQ score < 95'
95 - <105 = '95 <= IQ score < 105'
105 - <115 = '105 <= IQ score < 115'
115 - <125 = '115 <= IQ score < 125'
125 - <135 = '125 <= IQ score < 135'
135 - <145 = '135 <= IQ score < 145'
145 - <155 = '145 <= IQ score < 155'
;
RUN;
/* *************************** Frequency table of the grouped IQ score **************************** */
PROC FREQ DATA = IQ;
TABLES IQ;
FORMAT IQ IQ.;
RUN;
Upvotes: 0
Views: 193
Reputation: 3117
Look in your code to see if there is any reference to a PROC FORMAT
. Although SAS provides a large number of ready made FORMATS and INFORMATS, it is often necessary to create formats
designed for a specific purpose.
They can be created through PROC FORMAT
and can be used to:
In your case, the user-defined format IQ. will convert the numeric variable iq
to character values.
data have;
input iq iq_fmt;
format iq_fmt iq.;
cards;
80 80
100 100
110 110
130 130
150 150
;
iq iq_fmt
80 75 <= IQ score < 85
100 95 <= IQ score < 105
110 105 <= IQ score < 115
130 125 <= IQ score < 135
150 145 <= IQ score < 155
Simple formats are created using the VALUE
statement of the PROC FORMAT
. It includes the name of the format to be created and the paired
mapping of values (on the left of the = sign) and what those values will be mapped to (on the right of the = sign). As an example, if the value is between 75 and 85 (not incl.) the resulting value will be 75 <= IQ score < 85
In the above example, iq
and iq_fmt
are identical columns. I apply the IQ. format to the iq_fmt
column. You can see that, for the first observation, the value of iq is 80
, thus mapped to 75 <= IQ score < 85
in the iq_fmt
column.
More details available in Building and Using User Defined Formats
Upvotes: 1
Reputation: 51566
The syntax for a FORMAT specification is the format name followed by an optional width followed by a period followed by an option decimal width.
A variable name cannot contain a period, so the PERIOD is what allows SAS to recognize that as a FORMAT specification instead of another variable name.
The FORMAT statement is used to attach a FORMAT specification to one or more VARIABLES. In your statement:
FORMAT IQ IQ. ;
The list of variables is just the single variable IQ and the format to be applied is IQ. , which will use the default width defined with the IQ format since there is no width listed.
Upvotes: 1