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

 

I created some dummy data

 

Data crop;
input season $ farm $ food $ amount;
datalines;
Fall'13 Florida apples 23
Spr'14 Florida apples 18
Sumr'14  Florida apples 19
Fall'13 Alabama apples 23
Spr'14 Alabama apples 25
Sumr'14  Alabama apples 24
Fall'13 Georgia apples 12
Spr'14 Georgia apples 14
Sumr'14  Georgia apples 11
Fall'13 Florida oranges 50
Spr'14 Florida oranges 48
Sumr'14  Florida oranges 32
Fall'13 Alabama oranges 10
Spr'14 Alabama oranges 9
Sumr'14  Alabama oranges 8
Fall'13 Georgia oranges 26
Spr'14 Georgia oranges 18
Sumr'14  Georgia oranges 11
;
run;

proc tabulate data=crop;
class season farm food;
var amount;
tables food*amount, farm*(season);
run;

 

and it made

 

   farm        
   Alabama  Florida  Georgia  
   season  season  season  
   Fall'13Spr'14Sumr'14Fall'13Spr'14Sumr'14Fall'13Spr'14Sumr'14
food           
applesamountSum232524231819121411
orangesamountSum10985048322618

11

 

 

 

 

 

I want to create a new row that sums  each column

 

   farm        
   Alabama  Florida  Georgia  
   season  season  season  
   Fall'13Spr'14Sumr'14Fall'13Spr'14Sumr'14Fall'13Spr'14Sumr'14
food           
applesamountSum232524231819121411
orangesamountSum1098504832261811
Total  3334367366413832

22

 

 

 

However if I try using the all statement

 

proc tabulate data=crop;
class season farm food;
var amount;
tables food*amount all, farm*(season);
run;

it produces

 

   farm        
   Alabama  Florida  Georgia  
   season  season  season  
   Fall'13Spr'14Sumr'14Fall'13Spr'14Sumr'14Fall'13Spr'14Sumr'14
food           
applesamountSum232524231819121411
orangesamountSum1098504832261811
All N222222222

 

Any help would be appreciated

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Try instead:

 

proc tabulate data=crop;
class season farm food;
var amount;
tables (food all)*amount, farm*season;
run;
PG

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

Try instead:

 

proc tabulate data=crop;
class season farm food;
var amount;
tables (food all)*amount, farm*season;
run;
PG
Bootler
Fluorite | Level 6

Thanks I thought I tried that, but I guess I did not. 🙂

That's what happens when you stare at a problem too long.

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
  • 2 replies
  • 1451 views
  • 0 likes
  • 2 in conversation