This is my first post here. I would like to create mutiple tables by using proc tabulate. I have 20 different names in the variable called 'group', and would like to create 20 tables for each of the group. I could restrict each group in WHERE statement within proc tabulate. But rather than write my codes 20 times, I'm wondering if there is a way to put macro in there. Appreciate any suggestions.
You have a couple of relatively simple choices (no macro language needed).
(1) Sort your data by this GROUP variable, and run a single PROC TABULATE adding the statement BY GROUP;
(2) If your table is two-dimensional, add a third dimension which would be GROUP. For this to be the paging dimension of the table, it has to appear first:
tables GROUP, (row dimension), (column dimension);
Good luck.
Thank you so much! It provides me a new approach, but I kinda would like to gerenerate 20 tables seperately, because I'd like to export each table into one spreadsheet within one big excel workbook.
Thank you! very helpful!
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.