- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Need below data in Million Dollar format.
Data:
629777257.7 | 3063114.557 | 47687382.31 | 31371401.09 |
548907467.6 | 7475029.274 | 30882553.57 | 26616491.86 |
Expected Format;
$ 630 MM | $ 3 MM | $ 48 MM | $ 31 MM |
$ 549 MM | $ 7 MM | $ 31 MM | $ 27 MM |
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It'd be nice if you didn't change your requirements as you go.
This does what you asked. Modify to suit if your needs change again.
proc format;
picture million (ROUND)
low -< 0 = '000,000,000,000,009)' (prefix="($ ")
0 = 'Zero'
0 - 1e6 = '1 Million'
1e6 <-< 10e6 = '000,000,009 M' (prefix=" $ " mult=0.000001)
10e6 - high = '000,000,009 Million' (prefix=" $ " mult=0.000001)
;
run;
data _null_;
A = 1.2; putlog A= million. ;
A = -629777257.2; putlog A= million. ;
A = 629777257.2; putlog A= million. ;
A = 3063114.2; putlog A= million. ;
run;
A=1 Million
A=($ 629,777,257)
A=$ 630 Million
A=$ 3 M
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This can get you started
proc format;
picture bigmoney (fuzz=0)
1E06-<1000000000='0000 M' (prefix='$' mult=.000001)
1E09-<1000000000000='0000 B' (prefix='$' mult=1E-09)
1E12-<1000000000000000='0000 T' (prefix='$' mult=1E-012);
run;
data mult;
do i=5 to 12;
x=16**i;
put x=comma20. x= bigmoney.;
end;
run;
Results:
LOG
Formatted Millions, Billions, and Trillions Dollar Amounts
x=1,048,576 x=$1 M
x=16,777,216 x=$16 M
x=268,435,456 x=$268 M
x=4,294,967,296 x=$4 B
x=68,719,476,736 x=$68 B
x=1,099,511,627,776 x=$1 T
x=17,592,186,044,416 x=$17 T
x=281,474,976,710,656 x=$281 T
This isn't exactly what you want but should be enough for you to figure out the solution from here.
@Cho8 wrote:
Need below data in Million Dollar format.
Data:
629777257.7 3063114.557 47687382.31 31371401.09 548907467.6 7475029.274 30882553.57 26616491.86
Expected Format;
$ 630 MM $ 3 MM $ 48 MM $ 31 MM $ 549 MM $ 7 MM $ 31 MM $ 27 MM
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I had similar idea 🙂
proc format;
picture milion (ROUND)
low - high = '000,000,000 MM' (prefix="$ " mult=0.000001)
;
run;
B-)
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc format;
picture bigm (ROUND)
low - high = '000,000,000,000 M' (prefix="$ " mult=0.000001)
;
run;
I have defined format like the above..
but iam not able to dispaly the below number in Million format. Please advise
2.047219393619E-09
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Cho8 ,
You right, with the one I provided you won't be do display this number, sorry for that. I've mad an update.
proc format;
picture milion (ROUND)
low -< 0 = '000,000,009 MM' (prefix="-$ " mult=0.000001)
0 = '0 MM'
0 <- high = '000,000,009 MM' (prefix=" $ " mult=0.000001)
;
run;
data _null_;
x = 2.047219393619E-09;
put x = /
x = 32.16 /
x = milion. ;
run;
All the best
Bart
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
-64684149.4007373
the negative number to be displayed like ($ 64,684,149). it should not take Million format.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Ok, one more update:
proc format;
picture milion (ROUND)
low -< 0 = '000,000,000,000,009)' (prefix="($ ")
0 = '0 MM'
0 <- high = '000,000,009 MM' (prefix=" $ " mult=0.000001)
;
run;
data _null_;
x = 2.047219393619E-09;
put x = /
x = 32.16 /
x = milion. ;
x = -64684149.4007373;
put x = /
x = 32.16 /
x = milion. ;
x = 64684149.4007373;
put x = /
x = 32.16 /
x = milion. ;
run;
B-)
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks..
its not converting ENotation into $M Format..
its giving Enotation value..
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
it does:
1 data _null_;
2 x = 6.46841494007373E7;
3 put x = /
4 x = 32.16 /
5 x = milion. ;
6 run;
x=64684149.401
x=64684149.4007373000000000
x=$ 65 MM
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
Bart
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
i have to store it in datset alongside other variables,to use it for further calculations.
i have to use FORMAT stmt..
but while using FORMAT it still showing Enotation..
is there a way to display using FORMAT..stmt.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Could you share some code? It will be easier.
Bart
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
When I run this:
proc format;
picture bigm (ROUND)
low -< 0 = '000,000,000,000,009)' (prefix="($ ")
0 = '0 MM'
0 <- high = '000,000,009 MM' (prefix=" $ " mult=0.000001)
;
run;
data test;
Stress2008 = 2.047219393619E-09;
Base2 = 600599374.795993;
format Base2 Stress2008 bigm.;
run;
proc print data = test;
run;
I get the following output:
The SAS System Obs Stress2008 Base2 1 $ 0 MM $ 601 MM
I don't understand what is not ok?
Bart
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It's very unusual to see three SET statements the way you've shown except in fairly complex programming for interleaving. Given the remainder of your code, I suspect you're doing something incorrectly at that stage.
@Cho8 wrote:
data euc.thirdrow(rename=(Base2=Base)); /* Should correct format of Base2*Base */
keep '$NCL'n Base2 Stress2008 ;
set euc.roll;
set euc.asofsep_sum1;
set euc.thirdrow_1 (drop='$NCL(Q3''20)'n);Stress2008=(Stress/(Base2*Base));
format Base2 Stress2008 bigm.;run;
Stress2008=2.047219393619E-09
Base2 =600599374.795993($601M)
i need Stress2008 also in $M format..
i can display Base2 as $601M using FOrmat bigm.,but not Stress2008
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Cho8 Here is a solution by @ChrisNZ that you may have already checked. Just in case-
https://communities.sas.com/t5/SAS-Programming/Format-Billions-as-0-0-B/td-p/491433