Help using Base SAS procedures

Proc Summary Help

Accepted Solution Solved
Reply
Regular Contributor
Posts: 212
Accepted Solution

Proc Summary Help

[ Edited ]

 

Hi. I have some output that doesn't quite match my requirements. In the Proc Summary below I need to add some missing components:

 

1.  a total count of all AD_DTs for each Rule_Order

2. AD_DT's should display in a MM/DD/YYY format

 

Sample data attached.

 

Any help would be greatly appreciated.

 

PROC SUMMARY data=FinalData print;
CLASS rule_order ad_dt;
run;

 

          The SUMMARY Procedure

                                             RULE_ORDER               AD_DT    N Obs
                                           -----------------------------------------
                                                      1    14MAR16:00:00:00        5

                                                           15MAR16:00:00:00        3

                                                           16MAR16:00:00:00       14

                                                           17MAR16:00:00:00       13

                                                           18MAR16:00:00:00       20

                                                           19MAR16:00:00:00       19

                                                           22MAR16:00:00:00        4

                                                           25MAR16:00:00:00        2

                                                    1.5    15MAR16:00:00:00        1

                                                           17MAR16:00:00:00        1

                                                           18MAR16:00:00:00        2

                                                           19MAR16:00:00:00        6

                                                           21MAR16:00:00:00       12

                                                           22MAR16:00:00:00        4

                                                           23MAR16:00:00:00        7

                                                           24MAR16:00:00:00       18

                                                           25MAR16:00:00:00      110
                                           -----------------------------------------

 


Accepted Solutions
Solution
‎04-06-2016 02:12 PM
Super User
Posts: 10,483

Re: Proc Summary Help

Since your current data apparently is a datetime you could change the value to be a date in a data step using:

 

data want;

   set FinalData;

   at_dt = datepart(at_dt);

   format at_dt mmddyy10.;

run;

 

If you use an output statement to generate an output data set it will contain several combinations of the class variables.

But it sounds like you may want a report procedure:

 

Proc tabulate data=want;

   class Rule_Order ad_dt;

   table rule_order*(ad_dt all)*n;

run;

View solution in original post


All Replies
Super User
Posts: 17,784

Re: Proc Summary Help

Can you provide sample data. In a problem like this it's important to replicate the issues you're having. 

 

Regular Contributor
Posts: 212

Re: Proc Summary Help

Sample data attached.  Thanks.

Solution
‎04-06-2016 02:12 PM
Super User
Posts: 10,483

Re: Proc Summary Help

Since your current data apparently is a datetime you could change the value to be a date in a data step using:

 

data want;

   set FinalData;

   at_dt = datepart(at_dt);

   format at_dt mmddyy10.;

run;

 

If you use an output statement to generate an output data set it will contain several combinations of the class variables.

But it sounds like you may want a report procedure:

 

Proc tabulate data=want;

   class Rule_Order ad_dt;

   table rule_order*(ad_dt all)*n;

run;

Regular Contributor
Posts: 212

Re: Proc Summary Help

Thanks.  The format doesn't seem to take affect in the Proc Summary or Proc Tabulate, I'm not sure why?  Do I have to indicate that I want the format used in the Proc?

 

I see that the Proc Tabulate is much closer to what I want, but it doesn't seem to have a total for Missing Values.  Can I add something for this?

 

 

Super User
Posts: 17,784

Re: Proc Summary Help

/Missing in Class statement

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 518 views
  • 0 likes
  • 3 in conversation