SAS Enterprise Guide

Desktop productivity for business analysts and programmers
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
VarunD
Obsidian | Level 7

Hi,

How do I display negative currency values in SAS list report in paranthesis ? Also, preferably with a red text.

I could do it easily in excel by creating a custom format but can't find my way around it in SAS EG.

 

Thanks in anticipation,
Varun

 

1 ACCEPTED SOLUTION

Accepted Solutions
SuryaKiran
Meteorite | Level 14

Try nlmny10. or rstdodn10. format, this should work.

Thanks,
Suryakiran

View solution in original post

7 REPLIES 7
VarunD
Obsidian | Level 7

Hi, Thanks.

 

I already tried that. It is for numeric values only. My values need to be displayed with a preceding $ sign.

SuryaKiran
Meteorite | Level 14

Try nlmny10. or rstdodn10. format, this should work.

Thanks,
Suryakiran
ballardw
Super User

@SuryaKiran wrote:

Try nlmny10. or rstdodn10. format, this should work.


may need to add some decimals if you want them to the format.

 

Text color is going to be ODS style dependent though color overrides are available in report procedures such as Proc Print, Report and tabulate.

Example formatting a text color based on the numeric value:

proc format library=work;
value agecolor
11='red'
12='pink'
13='blue'
14='orange'
other='black'
;
run;

proc print data=sashelp.class;
   var age /style=[foreground=agecolor.];
run;

 

VarunD
Obsidian | Level 7
Thanks a lot. This worked for displaying the negative values in parenthesis.
Reeza
Super User

Numeric formats can have a $ sign. I suspect here you may need to roll your own. I think for the colour aspect, it will need some sort of styling elsewhere, but the negative value with parenthesis is probably a picture format. 

 


@VarunD wrote:

Hi, Thanks.

 

I already tried that. It is for numeric values only. My values need to be displayed with a preceding $ sign.


 

Patrick
Opal | Level 21

@VarunD wrote:

Hi, Thanks.

 

I already tried that. It is for numeric values only. My values need to be displayed with a preceding $ sign.


Below code a combination of what others wrote already. You will still have to tweak it a bit but it should point you into the right direction.

data have;
  do value=-150 to 150 by 50;
    output;
  end;
  stop;
run;

proc format library=work;
value currcol
  low-<0  ='red'
  0       ='green'
  other   ='black'
  ;
picture myp(default=10)
  low-0='00009)'(prefix='( $')
  other='00009'(prefix='$')
  ;
run;

proc print data=have;
   format value myp.;
   var value /style=[foreground=currcol.];
run;

 

Capture.JPG

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!

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 5303 views
  • 1 like
  • 6 in conversation