SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
thanikondharish
Calcite | Level 5

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
tomrvincent
Rhodochrosite | Level 12
data ex;
format number percent9.2;
number=1.02;
run;
data_null__
Jade | Level 19

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%
Ksharp
Super User
proc format;
picture fmt
low-high='000.99%';
run;

data ex ;
number=102 ;
format number fmt. ;
run;
ed_sas_member
Meteorite | Level 14

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;
Ksharp
Super User

proc format has such kind of option ROUND .

 

proc format;
picture fmt(round)
low-high='999.99%';
run;
Tom
Super User Tom
Super User

To convert 102 into 102% you just need to divide it by 100.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 7 replies
  • 9721 views
  • 0 likes
  • 7 in conversation