BookmarkSubscribeRSS Feed
Anilsk
Fluorite | Level 6
I have done a simple computation for percentage as
data td.sample;
set td.sample;
Percentage=(total/3);
run;
proc print data=td.sample;
run;

It is working fine, new column Percentage comes up with the right values, but i want to add "%" symbol along with each data values in the Percentage Column

like

Percentage
45.33333%
49.66667%
55%
63%
63.66667%
65.33333%
80.33333%
86%

and i also want to limit the decimal space for two digits.
3 REPLIES 3
DataShare
SAS Employee
1. using custom format
proc format lib=library;
picture perc low-high ='000.00 %';
run;
data Test1;
c1=1.1234;
run;
data Test2;
format c2 perc.;
set Test1;
c2=c1;
run;

2. read about percentw.d format
andreas_lds
Jade | Level 19
You can change the value of the calculated variable to include the %-symbol, but I recommend using the format statement to change the way the value is displayed.
[pre]data td.sample;
set td.sample;
format Percentage percent10.2;
Percentage=(total/300);
run;[/pre]
Please notice the description of the format found in the SAS online documentation:
The PERCENTw.d format multiplies values by 100, formats them the same as the BESTw.d format, and adds a percent sign (%) to the end of the formatted value, while it encloses negative values in parentheses.
Anilsk
Fluorite | Level 6
Thanks andreas_lds , It worked!!!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2857 views
  • 0 likes
  • 3 in conversation