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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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