BookmarkSubscribeRSS Feed
xappppp
Calcite | Level 5

in proc tabulate, if the case is simply like this

---------------------------------------------------

TABLE Gender*Blood,

              City*n;

---------------------------------------------------

Then I will get a table like following:

GenderBloodChicago

LA

MA14
B23
FA32
B41

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.

GenderBloodChicago

LA

MA14
MB23
FA32
FB41
4 REPLIES 4
ballardw
Super User

What do you want?

xappppp
Calcite | Level 5

clearly as the second table shows, in want the first row class (gender) with levels unmerged.

ballardw
Super User

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.

Cynthia_sas
SAS Super FREQ

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


report_fillin_rows.png

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1942 views
  • 0 likes
  • 3 in conversation