in proc tabulate, if the case is simply like this
---------------------------------------------------
TABLE Gender*Blood,
City*n;
---------------------------------------------------
Then I will get a table like following:
Gender | Blood | Chicago | LA |
---|---|---|---|
M | A | 1 | 4 |
B | 2 | 3 | |
F | A | 3 | 2 |
B | 4 | 1 |
Where you can see the gender column cells are merged within each level and with only one input. How can I have the cell unmerged and with the levels repeated in each row. like following. I know proc report probably can do this similar thing. but my tables are really complicated with all kinds of statistics and i wanna stick with proc tabulate. let me know if anyone have some good idea.
Gender | Blood | Chicago | LA |
---|---|---|---|
M | A | 1 | 4 |
M | B | 2 | 3 |
F | A | 3 | 2 |
F | B | 4 | 1 |
What do you want?
clearly as the second table shows, in want the first row class (gender) with levels unmerged.
When I first looked at your post the tables didn't show.
Depending on the statistics and other complexity of the tables I have often preprocessed the data using summary or even tabultate to get the statistics ant then used tabulate or sometimes proc print to display similar results.
Hi:
The way that TABULATE works with using the asterisk (*) operator, whether there are 19 levels of blood or 2 levels of blood within GENDER, then the rows for GENDER will span the rows for BLOOD.
TABLE Gender*Blood, City*n;
There is no way in TABULATE to repeat nested or crossed values on every row (such as for GENDER), because, by default, TABULATE wants to make you a "nice" table with the "spanning" behavior. PROC REPORT would do what you want. But you said that you need TABULATE for "all kinds of statistics". REPORT has all the same statistics except the keywords for percentages and the KURTOSIS and SKEWNESS. And, because REPORT has the COMPUTE block, you could still calculate row percents or col percents if you needed to. Kurtosis and skewness are probably the only deal breakers, then.
cynthia
pix of REPORT output with LOTS of statistics and repeated values
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.