Sentry Page Protection
Variable Attributes [9-17]
The Format of W.D
The format of W.D displays the numeric data in different decimal places.
Example
Example
In this data set, Num1 and Num2, again, contain an identical set of data.
Example: (4 decimal places)
Data WD1;
Set Num;
Format Num2 10.4;
Run;
The format of (10.4) is assigned to the variable Num2.
The value is now displayed at 4 decimal places.
E.g. 12345.67 --> 12345.6700
The Structure of W.D Format
The format of (10.4) is an example of W.D where
- W = 10 and
- D = 4
D represents the decimal places to display (4).
W is the minimum digits needed for the display of the full value.
E.g. Data = 12345.6700
- 12345 = 5 digits
- .(dot) = 1 digit
- 6700 = 4 digits
In this example, we need at least 10 digits to display the full value of the data:
As a result, the format (10.4) is used.
Example (3 decimal places)
Data WD2;
Set Num;
Format Num2 9.3;
Run;
Since there are only 9 digits to display, the format of 9.3 (W=9, D=3) is used to display the value at 3 decimal places.
Example (0 decimal place)
Data WD3;
Set Num;
Format Num2 5.0;
Run;
Reminder
No matter what format is assigned to a variable, only the display of the value changes.
In our example, Num1 and Num2 still contain identical data regardless of the formats applied to the variable.
Exercise
Copy and run the RNumber data set from the yellow box below.
Copy and run the RNumber data set from the yellow box below.
Display the NUM1 variable at 4 decimal places.
Create any data set or variable if needed.
Need some help?
HINT:
Apply the format based on the value that requires the largest number of digits.
SOLUTION:
Data RNumber2;
Set RNumber;
Format Num1 13.4;
Run;
Fill out my online form.