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!!!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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