Desktop productivity for business analysts and programmers

display negative currency values in paranthesis

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

display negative currency values in paranthesis

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

 


Accepted Solutions
Solution
‎04-09-2018 01:19 PM
Super Contributor
Posts: 448

Re: display negative currency values in paranthesis

[ Edited ]

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

Thanks,
Suryakiran

View solution in original post


All Replies
PROC Star
Posts: 1,287

Re: display negative currency values in paranthesis

Occasional Contributor
Posts: 13

Re: display negative currency values in paranthesis

Posted in reply to novinosrin

Hi, Thanks.

 

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

Solution
‎04-09-2018 01:19 PM
Super Contributor
Posts: 448

Re: display negative currency values in paranthesis

[ Edited ]

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

Thanks,
Suryakiran
Super User
Posts: 12,994

Re: display negative currency values in paranthesis

[ Edited ]
Posted in reply to SuryaKiran

@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;

 

Occasional Contributor
Posts: 13

Re: display negative currency values in paranthesis

Posted in reply to SuryaKiran
Thanks a lot. This worked for displaying the negative values in parenthesis.
Super User
Posts: 22,820

Re: display negative currency values in paranthesis

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.


 

Respected Advisor
Posts: 4,536

Re: display negative currency values in paranthesis

[ Edited ]

@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

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 214 views
  • 1 like
  • 6 in conversation