data ex ;
number=102 ;
format number percent7.2 ;
run;
value should be come like 102.00% .
I have tried above program it is not working.
Percent values are kept in SAS as relational values, so 102% is stored as 1.02 and displayed as 102.00% by the percent format.
The PERCENT and PERCENTN format multiply by 100 so the value to be displayed should be a proportion.
35 data _null_;
36 do number=102,-102,1.02,-1.02;
37 put number=percentn12.2;
38 end;
39 run;
number=10200.00%
number=-10200.00%
number=102.00%
number=-102.00%
proc format;
picture fmt
low-high='000.99%';
run;
data ex ;
number=102 ;
format number fmt. ;
run;
You can also add the round() function to avoid truncation
proc format;
picture fmt
low-high='999.99%';
run;
data ex ;
number=102 ;
number2 = round(number,.01);
format number2 fmt.;
run;
proc format has such kind of option ROUND .
proc format;
picture fmt(round)
low-high='999.99%';
run;
To convert 102 into 102% you just need to divide it by 100.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.