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

Hello

I wan to add Total row under each score and also grand total row.

So there will be extra 3 total rows (one for score 'a' , second for score 'b'  and 3rd for grand total

What is the way to do it please using proc tabulate?

 

Data rawtbl;
informat ddate date9.;
format ddate date9.;
input ID ddate score $ Y;
cards;
1 '10NOV2019'd a 100
2 '10NOV2019'd a 200
3 '10NOV2019'd a 250
4 '10NOV2019'd b 300
5 '10NOV2019'd b 50
6 '11NOV2019'd b 150
7 '11NOV2019'd b 100
8 '11NOV2019'd a 200
9 '11NOV2019'd a 250
10 '12NOV2019'd a 300
11 '12NOV2019'd a 50
12 '12NOV2019'd b 150 
;
run;

title;
proc tabulate data=rawtbl f=6. out=want;
class score  ddate;
var Y;
tables score*ddate, Y*(sum PCTN);
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Ronein
Onyx | Level 15

Great!! I got solution

 

title;
proc tabulate data=rawtbl f=6. out=want;
class score  ddate;
var Y;
tables score *(ddate All='total') ALL, Y*(sum PCTN);
run;

View solution in original post

5 REPLIES 5
andreas_lds
Jade | Level 19
Have a look at the docs, you have to place the keyword ALL in the row-part of the tables-statement.
Ronein
Onyx | Level 15

When I add ALL  then I get global total.

It is good but I need also to get total after each score...

title;
proc tabulate data=rawtbl f=6. out=want;
class score  ddate;
var Y;
tables score *ddate ALL, Y*(sum PCTN);
run;
Ronein
Onyx | Level 15

Great!! I got solution

 

title;
proc tabulate data=rawtbl f=6. out=want;
class score  ddate;
var Y;
tables score *(ddate All='total') ALL, Y*(sum PCTN);
run;
Ronein
Onyx | Level 15

It is a bit confusing because I add total for each score and not for each date......but in the code I need to add ALL keyword near date and not not near score

andreas_lds
Jade | Level 19

Sorry, i don't get it. Can you show want you want?

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