turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- General Programming
- /
- Proc tabulate - Specify different column statisti...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-15-2014 04:56 PM

Hello,

I am trying to create a simple table with variables a b and c as rows and I want the statistics N, SUM and mean to be displayed. However, I only want N displayed for variable A and sum and mean displayed for variable B and C like this:

N | SUM | MEAN | |
---|---|---|---|

A | 200 | ||

B | 100 | 0.5 | |

C | 40 | 0.2 |

PROC TABULATE DATA=ALL ;

VAR A B C;

TABLE A="A" B ="B" C="C"

, (N= "n" SUM="sum"*F=4.0 MEAN="mean") ;

RUN;

Is there any way to specify different column statistics for different row variables? I don't seem to be able to find any relevant options or examples in SAS documentation.

Thanks so much!

Sarasvati

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-15-2014 05:39 PM

Hi, it's not clear to me what your data set (WORK.ALL) looks like or why you would want a cross-tabular report without a count for B or C and without a SUM for A. Perhaps TABULATE is not the correct procedure for you to use for your data or for the report you want. Generally, you have your CLASS or category variables going down the rows and your numeric variables and the different statistics in the columns. You should be able to run the program below.

Cynthia

**ods html file='c:\temp\diff_stats.html';**

**proc tabulate data=sashelp.class;**

**title '1) Requesting Different Statistics in the Column Dimension';**

**class sex;**

**var height weight;**

**table sex all,**

** height*n height*mean weight*mean weight*css;**

**run;**

**proc tabulate data=sashelp.class;**

**title '2) Requesting Different Statistics in the Row Dimension';**

**class sex;**

**var height weight;**

**table height*n height*mean weight*mean weight*css,**

** sex;**

**run;**

**proc tabulate data=sashelp.class;**

**title '3) Requesting Different Statistics Without a Category Variable';**

**var height weight;**

**table height*n height*mean weight*mean weight*css,**

** all;**

**run;**

**ods html close;**

**title;**

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-15-2014 08:33 PM

Hi Cynthia,

Thank you for your response. Apologies for not being clearer but allow me to clarify.

I have a dataset of say 200 observations and a number of dichotomous variables coded as 0/1.

I initially created a simple table which produces a row for each dichotomous variable containing the following statistics:

- N (Total observations),
- SUM (number of positive responses)
- MEAN (formatted as a %) to given me the % of positive responses.

If i use these dichotomous variables as class variables I get the zero category as well which I do not want.

However, I now wish to instead put the total number of observations on a row by itself and then list the N (%) for the responses. I have a specific reason that is unique to my problem for wanting to present it in this way.

Variable Cohort Total Number positive responses % pos responses

200

VAR1 50 25.0%

VAR2 25 12.5%

VAR3 40 20.0%

It is pretty easy to create the table and later edit out the unwanted numbers in a word processor but i wanted to automate the process.

Any insight into the code that could accomplish this would be appreciated!