It appears that you are looking for different combinations of summaries. That might make proc summary even more attractive.
Please examine the output data set from this code:
proc summary data=sashelp.class;
class sex age;
var height;
output out=work.classsummary mean=;
run;
You will see a variable called _type_ that in this case has values from 0 to 3. The _type_=0 is the summary, mean in this case, across all records in the data set; _type_=1 is the summary only for the levels of Age; _type_ =2 is the summary for levels of Sex ; _type_=3 is the summary for the combined levels of sex and age.
If you have a variable that has missing values that you want considered as a separate level then you use the option /missing on a class statement. You can have more than one class statement with different options but ALL of the variables on the class statements will be used to get different summaries.
If you only want specific records after a summary step then a data step can select or modify.
You can also summarize many variables and request different statistics. The /autoname option on the OUTPUT statement creates output variables with the statistic appended to the variable name if you don't want to create different variables by hand.
If you have actual SAS date values you can use the format applied to a variable to create groups. ( and a WHERE to restrict the range if desired). You should have the SASHELP.STOCKS data set available to see this code. I am creating a custom date format as the SAS supplied YYMM format places an M in the value. Note that the first proc summary step creates a summary of the overall min and max of all of the stock open and close values over the period of time in the data; a summary by calendar month of min and max open and close across all stocks, the min and max of the stock open and close across the time period and the min and max open and close value for each stock and month combination.
The second proc summary does the exact same thing but groups by calendar quarter instead of month. A different format could do the same for calendar years. Custom formats could be made for many types of intervals not supplied by SAS using Proc Format and some ingenuity.
proc format library=work;
picture my_ym (default=6)
low-high='%Y%0m' (datatype=date);
run;
proc summary data=sashelp.stocks;
class stock date;
format date my_ym.;
var open close;
output out=work.stocksummary min= max= /autoname;
run;
proc summary data=sashelp.stocks;
class stock date;
format date yyq6.;
var open close;
output out=work.stocksummary2 min= max= /autoname;
run;
... View more