- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 !!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
thanks Reeza.
I see A=000,000,010.10 in the log now!
Is there a way to do this using SAS formats ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Awesome!!
Thanks!! 🙂