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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.