How to display values in percent format in SAS?

In SAS, one can display values in percent format by using the Percentw.d format, where w is the total width of the output field and d is the number of decimal places. For example, the format statement Percent7.2 specifies 7 characters for the output field, with a maximum of 2 decimal places. This format can then be used to display a value such as 0.125 as 12.50%.


You can use the PERCENT format option in SAS to print values formatted as percentages.

The following example shows how to use the PERCENT format option in practice.

Example: Display Values in Percent Format in SAS

Suppose we have the following dataset in SAS that shows the exam scores of students in some class:

/*create dataset*/
data my_data;
    input student $ exam_score;
    datalines;
Andy 0.945
Bob 0.78
Chad 0.865
Derrick 0.77
Eric 0.75
Frank 0.64
George 0.895
Henry 0.98
Isaac 0.68
John 0.84
;
run;

/*view dataset*/
proc print data=my_data;

Suppose we would like to format the values in the exam_score column using a percent format.

We can use the following syntax to do so:

/*view dataset and display exam scores in percent format*/
proc print data=my_data;
    format exam_score percent10.1;
run;

Each value in the exam_score column is displayed in a percent format.

When using the percent10.1 statement, the 10 specifies that a maximum of 10 characters will be needed to display the entire value including the percent symbol while the 1 specifies that 1 digit should be shown after the decimal place.

If you don’t want to display any values after the decimal place, you can use percent10. instead:

/*view dataset and display exam scores in percent format without decimal places*/
proc print data=my_data;
    format exam_score percent10.;
run;

Notice that each value in the exam_score column is rounded to the nearest integer and each value after the decimal place has been truncated.

Note: You can find the complete documentation for the PERCENT format in SAS .

The following tutorials explain how to perform other common tasks in SAS:

x