Help using Base SAS procedures

Inserting symbols in data values

Reply
Occasional Contributor
Posts: 8

Inserting symbols in data values

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.
SAS Employee
Posts: 13

Re: Inserting symbols in data values

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
Super Contributor
Posts: 264

Re: Inserting symbols in data values

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.
Occasional Contributor
Posts: 8

Re: Inserting symbols in data values

Thanks andreas_lds , It worked!!!
Ask a Question
Discussion stats
  • 3 replies
  • 113 views
  • 0 likes
  • 3 in conversation