BookmarkSubscribeRSS Feed
scb
Obsidian | Level 7 scb
Obsidian | Level 7

 

May I know how to get the total TYPE1 and total TYPE2 cases? The underlined total.  Thanks.

 

Example Output

                                            Type

                            Type1                         Type2

                  Done WIP  TOTAL   Done WIP  TOTAL

Period1          1      0       1           2        1        3

Period2          1      1       2           4         2       6

Total               2      1       3           6        3        9

 

DATA STATUS;
INPUT PERIOD $ STATUS $ TYPE $ CASE;
DATALINES;
201801 Done Type1 1
201801 Done Type2 1
201802 WIP Type1 1
201802 Done Type2 1
201802 Done Type1 1
201802 WIP Type2 1
201803 Done Type1 1
201803 WIP Type2 1
;
run;


proc tabulate data=status;
class Period Type Status ;
var case;
table
Period all='Total',
(Type*Status='')*(N=''*F=8.) / Misstext='0';
Run;

2 REPLIES 2
Patrick
Opal | Level 21

Thank you for posting sample data in the form of a working SAS datastep and then also showing us the desired result based on this sample data. Helping us makes it so much easier to help you.

Now to become perfect you just would also need to post the code into a code window using the running man icon Capture.JPG and then ideally also mark "the best/most helpful answer" as solution. I've "checked" on you and I have seen that many of your discussions are still "open" meaning you haven't marked one of the answers as solution.

 

Here what you could do:

proc tabulate data=status;
  class Period Type Status;
  var case;
  table
    Period all='Total',
    Type*(Status='' all='Total')*N=''*F=8. / Misstext='0';
Run;

Capture.JPG

 

And just in case you also need a total by Period:

proc tabulate data=status;
  class Period Type Status;
  var case;
  table
    Period all='Total',
    (Type*(Status='' all='Total') all='Total')*N=''*F=8. / Misstext='0';
Run;

Capture.JPG

 

Or this way - your pick

proc tabulate data=status;
  class Period Type Status;
  var case;
  table
    Period all='Total',
    ((Type all='Total')*Status='' all='Total')*N=''*F=8. / Misstext='0';
Run;

Capture.JPG 

ballardw
Super User

I would recommend for additional flexibility that you use actual date values instead of pseudo values like 201801.

Using an appropriate format with an actual date value you can duplicate that YYYYMM appearance but you could by just changing the format for the data variable get things like annual, quarterly or custom interval summaries.

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
  • 2 replies
  • 499 views
  • 1 like
  • 3 in conversation