BookmarkSubscribeRSS Feed
Eva
Quartz | Level 8 Eva
Quartz | Level 8
Dear all,

when using the percent format sas displays negatives values like this: (0.05%)
Instead I would like to have -0.05%.
Does anybody know how to do this?

Best regards
Eva
10 REPLIES 10
LAP
Quartz | Level 8 LAP
Quartz | Level 8
Use the percentnw.d format.

For example

x = -0.313 ;
format x percentn8.2;

results in -31.3%.

You must make sure the w.d is wide enough to include the negative sign and the percent.

See base documentation for further explanation

Linda
Eva
Quartz | Level 8 Eva
Quartz | Level 8
Dear Linda,

unfortunately we still user SAS 9.1 and percentn is only available at SAS 9.2
Do you know how to to it wth sas 9.1 ?

Best regards
Eva
Bill
Quartz | Level 8
Eva;

You could multipy by 100 to get the percent value. You could then concatenate a % symbol to the percent value or indicate that the column/row of numbers is expressed in percent. The latter is preferred if there is a column or row of numbers. To have the % symbol beside each number is distracting and clutters the display, aka, poor data visualization practice.

hth,
Bill
LAP
Quartz | Level 8 LAP
Quartz | Level 8
I'm using 9.1.3 and I tested the percentnw.d format. It seemed to work. However, I did have to widen the format to 8.2.

My other thought would be to use a picture format in proc format to define the format as follows.

proc format;
picture negpct low - < 0 = '000.00%' (prefix="-" )
0 - high = '000.00%' ;
run;

data test;
length x 8;
format y negpct.;
x = .031;y=x*100;output;
x = -0.435;y=x*100; output;

run;
LAP
Quartz | Level 8 LAP
Quartz | Level 8
Sorry not all went through....

proc format;
picture negpct low - < 0 = '000.00%' (prefix="-" )
0 - high = '000.00%' ;
run;

data test;
length x 8;
format y negpct.;
x = .031;y=x*100;output;
x = -0.435;y=x*100; output;

run;
LAP
Quartz | Level 8 LAP
Quartz | Level 8
Good grief Not sure how to get this to post....

'000.00%' (prefix = "-")
0 - high = '000.00%' ;
run;

You will have to multiply the number by 100 your self.

Hope this posts correctly now.

Linda




Message was edited by: LAP

Message was edited by: LAP Message was edited by: LAP
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
The topic is discussed here - found on the SAS support website with a SEARCH.

Scott Barry
SBBWorks, Inc.

Don't Be a SAS® Dinosaur: Modernizing Programs with Base SAS 9.2 Enhancements
Warren Repole Jr., SAS Institute Inc.- Figure 13a.
http://support.sas.com/resources/papers/proceedings09/143-2009.pdf
Cynthia_sas
Diamond | Level 26
Hi:
When you need to post code to the forum and particularly when your code has < or > symbols or you need the indenting to line up, this posting tells how to make that happen using special formatting commands:

http://support.sas.com/forums/thread.jspa?messageID=27609毙

cynthia
Eva
Quartz | Level 8 Eva
Quartz | Level 8
Dear Linda,

many thanks for your post. It works!
Here's your example - I hope it posts correctly:

[pre]
proc format;
picture negpct low - < 0 = '000.00%' (prefix="-" )
0 - high = '000.00%' ;
run;

data test;
length x 8;
format y negpct.;
x = .031;y=x*100;output;
x = -0.435;y=x*100; output;

run;
[/pre]

Best wishes
Eva
FredrikE
Rhodochrosite | Level 12
Hi!
If intend to use picture format you do not have to multiply the value it is in the picture.....

proc format;
picture negpct
0 - high = '009.999%' (mult=100000)
low - 0 = '009.999%' (prefix='-' mult=100000)
;
run;
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 10 replies
  • 14085 views
  • 4 likes
  • 6 in conversation