turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- format perecnt: erase parentheses for negative val...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-09-2009 10:32 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-09-2009 10:47 AM

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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-09-2009 10:57 AM

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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-09-2009 11:51 AM

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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-09-2009 01:02 PM

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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-09-2009 01:02 PM

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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-09-2009 01:04 PM

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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-09-2009 01:10 PM

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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-09-2009 01:42 PM

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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-10-2009 07:36 AM

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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-10-2009 09:24 AM

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;