- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 12-09-2019 08:30 AM
(9720 views)
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.
7 REPLIES 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data ex;
format number percent9.2;
number=1.02;
run;
format number percent9.2;
number=1.02;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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%
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc format;
picture fmt
low-high='000.99%';
run;
data ex ;
number=102 ;
format number fmt. ;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc format has such kind of option ROUND .
proc format;
picture fmt(round)
low-high='999.99%';
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
To convert 102 into 102% you just need to divide it by 100.