BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
P5C768
Obsidian | Level 7

Apologize for such a basic question but I cannot figure it out.  When I use the format below for numbers in the millions, it comes out as $n.n M, but a number in billions only comes out as $ n B, I would like to add the decimal place so that $1.5 billion would read as $1.5 B, not $1 B.  Thanks!

 

proc format;   
	picture money (fuzz=0)
	-1000000000000000-<-1E12='0000 T' (prefix='-$' mult=1E-012)
	-1000000000000-<-1E09='0000 B' (prefix='-$' mult=1E-09) 
	-1000000000-<1E06='0000 M' (prefix='-$' mult=.000001)
	1E06-<1000000000='0000 M' (prefix='$' mult=.000001)
	1E09-<1000000000000='0000 B' (prefix='$' mult=1E-09)
	1E12-<1000000000000000='0000 T' (prefix='$' mult=1E-012);
run;
1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

Like this?

proc format;   
 picture money (fuzz=0)
    -1E15 -< -1E12='0000 T' (prefix='-$' mult=1E-12)
    -1E12 -< -1E09='0000 B' (prefix='-$' mult=1E-09) 
    -1E09 -<  1E06='0000 M' (prefix='-$' mult=1E-06)
     1E06 -<  1E09='0000 M' (prefix= '$' mult=1E-06)
     1E09 -<  1E10='00.9 B' (prefix= '$' mult=1E-08)
     1E10 -<  1E12='0000 B' (prefix= '$' mult=1E-09)
     1E12 -<  1E15='0000 T' (prefix= '$' mult=1E-12);
run;


data t;
 A=3.3e07; put A A money.; 
 A=3.3e08; put A A money.;
 A=3.3e09; put A A money.;
 A=3.3e10; put A A money.;
run;

33000000 $33 M
330000000 $330 M
3300000000 $3.3 B
33000000000 $33 B

View solution in original post

1 REPLY 1
ChrisNZ
Tourmaline | Level 20

Like this?

proc format;   
 picture money (fuzz=0)
    -1E15 -< -1E12='0000 T' (prefix='-$' mult=1E-12)
    -1E12 -< -1E09='0000 B' (prefix='-$' mult=1E-09) 
    -1E09 -<  1E06='0000 M' (prefix='-$' mult=1E-06)
     1E06 -<  1E09='0000 M' (prefix= '$' mult=1E-06)
     1E09 -<  1E10='00.9 B' (prefix= '$' mult=1E-08)
     1E10 -<  1E12='0000 B' (prefix= '$' mult=1E-09)
     1E12 -<  1E15='0000 T' (prefix= '$' mult=1E-12);
run;


data t;
 A=3.3e07; put A A money.; 
 A=3.3e08; put A A money.;
 A=3.3e09; put A A money.;
 A=3.3e10; put A A money.;
run;

33000000 $33 M
330000000 $330 M
3300000000 $3.3 B
33000000000 $33 B

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

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
  • 1 reply
  • 3190 views
  • 2 likes
  • 2 in conversation