SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Ronein
Meteorite | Level 14

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
Meteorite | Level 14

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

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 1451 views
  • 3 likes
  • 3 in conversation