I am using dollar12. format in my proc report and for the negative values I get the negative sign "-" after the dollar sign ($-10)
Ideally, I would want the negative sign to be before the dollar sign (-$10)
Is there a way to do this?
data _null_;
A=-10.1;
putlog A= dollar12. ;
run;
Thanks !!
1. Change so that the default length will show the $
2. Change so that the other format is default dollar format for values above 0.
proc format;
picture mycurrencyfmt (default =22 )
low - 0 = '000,000,099.99' (prefix = '-$')
other = [dollar22.] ;
run;
data demo;
input value;
format value mycurrencyfmt.;
cards;
25
45
3993
34343434314
-3434343
-234
-2334
-34343413413413.23
;;;;
run;
proc print;run;
@new_sas_user_4 wrote:
Yes, this is what I ran:
proc format;
picture myCurrencyFmt
low - 0 = '999,999,999.99' (prefix = '-$')
0 - high = '999,999,999.99' (prefix = '$');
run;data _null_;
A=-10.1;
putlog A=myCurrencyFmt.;
run;
I got A=000,000,010.10 in the log!
I think you need a custom format.
Untested but something like this I assume, untested.
proc format;
picture myCurrencyFmt
low - 0 = '999,999,999.99' (prefix = '-$')
0 - high = '999,999,999.99' (prefix = '$');
run;
@new_sas_user_4 wrote:
I am using dollar12. format in my proc report and for the negative values I get the negative sign "-" after the dollar sign ($-10)
Ideally, I would want the negative sign to be before the dollar sign (-$10)
Is there a way to do this?
data _null_;
A=-10.1;
putlog A= dollar12. ;
run;
Thanks !!
Using the below I get : NOTE: Variable myCurrencyFmt is uninitialized.
A=-10.1
proc format;
picture myCurrencyFmt
low - 0 = '999,999,999.99' (prefix = '-$')
0 - high = '999,999,999.99' (prefix = '$');
run;
data _null_;
A=-10.1;
putlog A=myCurrencyFmt ;
run;
thanks Reeza.
I see A=000,000,010.10 in the log now!
Is there a way to do this using SAS formats ?
That is a format - note PROC FORMAT. Did you remember the prefix portion, why isn't that showing?
@new_sas_user_4 wrote:
thanks Reeza.
I see A=000,000,010.10 in the log now!
Is there a way to do this using SAS formats ?
Yes, this is what I ran:
proc format;
picture myCurrencyFmt
low - 0 = '999,999,999.99' (prefix = '-$')
0 - high = '999,999,999.99' (prefix = '$');
run;
data _null_;
A=-10.1;
putlog A=myCurrencyFmt.;
run;
I got A=000,000,010.10 in the log!
1. Change so that the default length will show the $
2. Change so that the other format is default dollar format for values above 0.
proc format;
picture mycurrencyfmt (default =22 )
low - 0 = '000,000,099.99' (prefix = '-$')
other = [dollar22.] ;
run;
data demo;
input value;
format value mycurrencyfmt.;
cards;
25
45
3993
34343434314
-3434343
-234
-2334
-34343413413413.23
;;;;
run;
proc print;run;
@new_sas_user_4 wrote:
Yes, this is what I ran:
proc format;
picture myCurrencyFmt
low - 0 = '999,999,999.99' (prefix = '-$')
0 - high = '999,999,999.99' (prefix = '$');
run;data _null_;
A=-10.1;
putlog A=myCurrencyFmt.;
run;
I got A=000,000,010.10 in the log!
Awesome!!
Thanks!! 🙂
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.