BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
weizhongma
Calcite | Level 5

I used following syntex to format the number to percentage. However for number of 0.858369, it gives 85%. Is there a way to get correct percetage of 0.85%?

proc format library = fmt;

picture pctfmt low-high='000.00%';

run;

Thanks!

Regards,

Weizhong

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

Hi,

Please try the below picture format

proc format;

picture val low-high='9.99%';

run;

data class;

    val=put(0.858369,val.);

run;

Thanks,

Jagadish

Thanks,
Jag

View solution in original post

8 REPLIES 8
Jagadishkatam
Amethyst | Level 16

Hi,

Please try the below picture format

proc format;

picture val low-high='9.99%';

run;

data class;

    val=put(0.858369,val.);

run;

Thanks,

Jagadish

Thanks,
Jag
weizhongma
Calcite | Level 5

Thanks! Jagadish. 

However my data mixed of numbers such as 20, 100 and 0.858369. If there way to wark around? Thanks!


Jagadishkatam
Amethyst | Level 16

in that case you can use the below picture format

proc format fmtlib;

    picture val low-<1='9.99%'

                1<-high='009%';

run;

Thanks,

Jagadish

Thanks,
Jag
data_null__
Jade | Level 19

What about 1.

Jagadishkatam
Amethyst | Level 16

Thank you data_null_, please find below my corrected code

proc format fmtlib;

    picture val low-<1='9.99%'

               1-high='009%';

run;

Thanks,

Jagadish

Thanks,
Jag
data_null__
Jade | Level 19

What about the sign if the value is negative?

Jagadishkatam
Amethyst | Level 16

Thank you data_null_, updated the picture format to consider the negative values

proc format fmtlib;

    picture val low-<0='09.99%' (prefix='-')

                0-<1='09.99%'

               1-high='009%';

run;

Thanks,

Jagadish

Thanks,
Jag
data_null__
Jade | Level 19

You need to RTM.  Look for the round option.  You will also need more digit selectors for the larger numbers and what about negative.

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!

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.

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
  • 8 replies
  • 3550 views
  • 0 likes
  • 3 in conversation