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 here.
Additional Resources
The following tutorials explain how to perform other common tasks in SAS:
How to Use Proc Summary in SAS
How to Use Proc Tabulate in SAS
How to Use Proc Rank in SAS