BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Ronein
Onyx | Level 15

Hello

I am runnning proc tabulate.

I want to display number in millions.

Instead of see the following numbers:

Ronein_0-1678003336009.png

Then I want to see it like that

Ronein_1-1678003379636.png

Here is the code I run

proc tabulate data=have;
class category/order=freq;
format category ;
var category   ;              ;
table category=' ' All='Total',
      n='Nr'*f=comma23. 
      pctn='PCT'*f=8.1
      category=' '*(sum='Sum_X'*f=comma23.1 pctsum='PCT_X'*f=8.1)/box='X'
   ;
run;
         

What is the way to dispaly the Sum_X  in millions?

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Data?

 

Custom format. The online documentation show one way.

 

proc format;
picture millions (round)
 low-high = '00,000,000,009' (mult=0.000001);
run;

data junk;
   input x;
datalines;
1
11
111
1111
11111
111111
1111111
11111111
111111111
1111111111
11111111111
111111111111
1111111111111
11111111111111
111111111111111
;

proc print data=junk;
  format x millions.;
run;

Did you even try anything that is pretty obviously a Proc Format question?

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

Divide SUM_X by one million.

 

Or create a PICTURE format to represent the value in millions. One nice thing with PICTURE formats is that they can be preceded by a $ character (if you want) and can have a suffix of M (if you want)

 

Example: https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/proc/n0kl9qj532rbqln187us4ao371h7.htm

--
Paige Miller
ballardw
Super User

Data?

 

Custom format. The online documentation show one way.

 

proc format;
picture millions (round)
 low-high = '00,000,000,009' (mult=0.000001);
run;

data junk;
   input x;
datalines;
1
11
111
1111
11111
111111
1111111
11111111
111111111
1111111111
11111111111
111111111111
1111111111111
11111111111111
111111111111111
;

proc print data=junk;
  format x millions.;
run;

Did you even try anything that is pretty obviously a Proc Format question?

Ronein
Onyx | Level 15

I have tried some codes and all didn't work well

picture millions (fuzz=0)
   low-high='0000 M' ( mult=.000001)
;
run;

May you explain why you put    11 numbers?

00,000,000,009

May you explain why you used this number

.000001 

PaigeMiller
Diamond | Level 26

@Ronein wrote:

I have tried some codes and all didn't work well

picture millions (fuzz=0) low-high='0000 M' ( mult=.000001) ; run;

You have to have enough space to show all the digits. Your code allows for just 4 places for digits.

 

May you explain why you used this number

.000001 

 

You might remember that earlier in this thread, I suggest a simple method of getting the results you want, that was dividing by one million. Question for you: dividing by one million is the same as multiplying by ___________________.

 

 

May you explain why you put    11 numbers?

00,000,000,009

 

 

These things you can figure out for yourself by experimenting ... change the code from @ballardw and see what happens.

--
Paige Miller

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1692 views
  • 3 likes
  • 3 in conversation