Cynthia@sas wrote:
Hi:
Since you have posted code, but NOT data, it is hard to visualize the output from your TABULATE step. The issues, that I see are two-fold: 1) not understanding that TABULATE needs to have something in the COLUMN dimension (you can have a table with only a COLUMN dimension, but you can't have a table with only a ROW dimension; and 2) all of your variables are CLASS variables, so you can only get N or PCTN or ALL in the COLUMN dimension. Clearly, your complaint is that you don't want the ALL or the N, but it's not clear to me what your CLASS variables represent. For example, I have made some FAKE data using SASHELP.PRDSALE, where I assigned P_V the value of PRODUCT. That way, I can run your same code, using variables that I had to guess about. As you can see in the screen shot, the left hand side of the table (for VARNAME, XCAT, NCP1, NCP2 and P_V) is in the "ROW" dimension (under the box area), and ALL is in the "COLUMN" dimension to the right of the box area.
The structure of your data will make a difference -- are all your variables character variables? have you pre-calculated any summary statistics? are you trying to produce something like the demographic report shown on page 9 of this paper (http://www2.sas.com/proceedings/forum2008/173-2008.pdf), which shows the multiple variable names/values going down the "row area" with different statistic values in the columns? (The demographic report in the paper was created with PROC REPORT.)
Without any data or any idea of why you don't want the ALL column, it is hard to make a constructive suggestion. TABULATE tables can have 1, 2 or 3 dimensions, but you do not get to pick what dimension shows for a 1-dimensional table -- it's always the COLUMN dimension. A 1-dim table only has COLUMNS; a 2-dim table has ROWS and COLUMNS; a 3-dim table has PAGES, ROWS and COLUMNS. So by the rules of TABULATE, you can't get a TABLE that is only ROWS. The first TABULATE step uses some FAKE data to show what your table looks like so it's easier for folks to visualize (see screen shot); the second TABULATE step illustrates 1, 2 and 3 dimensional tables using TABULATE table operators, like comma and parentheses and asterisk.
Given the code and the fake data, I don't understand what you want to produce. If your data are pre-summarized, then why not use PROC PRINT or PROC REPORT? The job of TABULATE is to group and summarize your table and to present it in tabular form. TABULATE isn't always a good choice for pre-summarized data. But, without knowing ANYTHING about your data, it's all just a guess what you want and what the values are in your data.
Cynthia
** make some fake data;
data cat_table; set sashelp.prdsale; varname = catx('~','varname',substr(country,1,1)); xcat = catx(' ','xcat',substr(division,1,1)); ncp1 = region; ncp2 = prodtype; p_v = product; run; ods listing close; ods html file='c:\temp\tabulate_question.html'; title; proc tabulate data=cat_table missing order=data; class varname xcat ncp1 ncp2 p_v; table varname*(xcat *ncp1 *ncp2 *p_v ), all; label varname='Variable Name' xcat="Xcat" ncp1='Level1' ncp2='Level2'; run; proc tabulate data=sashelp.prdsale; class country region product; var actual; table country ; /* 1-dim all columns */ table region, country / box='2-dim'; table product*region,country / box='2-dim nested row'; table product, region, country*actual*( probt median min max) / box='3-dim with numeric var'; run; ods html close;
Thanks Cynthia for this detailed answer, I am exactly trying to accomplish the same thing as in the paper. I have my summary statistics and p values pre calculated in a dataset and I want to use proc tabulate instead of report to display them. xcat- variable names ncp1- ncp2 - Variable counts concatenated with % p_v - pvalues I want something very similar to figure-8 from that paper but using tabulate. Thanks once again
... View more