@shoeGirl37 wrote:
So this works great! What if I want to add patientID as a grouping?
Depends on where you want it to appear and how a variable is to be used. That is partially why I mentioned which examples have which things appear in a row, column or page heading. Within any of the dimensions the code when read from left to right with nesting (the *) means that for rows (or page) that the variable values will appear in left to right order. If the dimension is a column dimension then the left most variable would be at the top of a group with the nested values below.
For simple counts I would suggest playing around with the variables in a smallish data set like SASHELP.Class or SASHELP.CARS and place the group-like variables in different orders with and without * for nesting and/or ( ) around groups of variables to see what happens. Or read the friendly manual. There are enough concepts involved that SAS publishes a book just on Proc Tabulate.
Also Proc Report is very flexible with different approaches to layout. There are tradeoffs in both procedures, Tabulate is probably nicer when you need to nest results in both rows and columns but you can't request statistics in both the row and column generally.
Proc Report allows more flexibility in using values from columns to calculate values in other columns to the right in a table.
Proc Tabulate needs to know how a variable will be used: Grouping usually means the variable goes on a Class statement, if the variable is be used in statistics other than N related, such as Mean, Max, Stddev then the variable needs to be on a VAR statement.
... View more