- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 11-09-2009 10:32 AM
(12555 views)
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
'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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
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;