BookmarkSubscribeRSS Feed
daisy6
Quartz | Level 8

Hi,

I use proc tabulate to create a table which belows,

Age

Microsoft IT

First-time

Total

Under 25

% Passing

23.3%

56.3%

Number Tested

111

234

26 to 29

% Passing

56.7%

47.2%

Number Tested

222

666

30 to 39

% Passing

68.2%

61.2%

Number Tested

111

333

 

my code is 

proc tabulate data=ttt ;
var pass first tot;
class examtitle age;
table age=" "*pass=" "*(mean="% Passing" n ), examtitle=" "*(first="First-time" tot="Total");
run;

first is the dummy variables which if it is first time exam taker. pass is the dummy variable if passing the exam then =1, fails are 0. tot is 1 for all the observations.

but the log shows: there are multiple analysis variables associated with a single table cell inthe following nesting.

please help! Thanks!

4 REPLIES 4
Astounding
PROC Star

Yes, you have one analysis variable used in the row definitions (PASS), and two analysis variables used in the column definitions (FIRST and TOT).  You will need to limit the analysis variables to a single variable per cell, which here means they must appear either in the row definitions only or in the column definitions only.

ballardw
Super User

table age=" "*pass=" "*(mean="% Passing" n ), <= this part of the table statement is requesting two statistics for the row: mean and N

        examtitle=" "*(first="First-time" tot="Total"); <= this part of the table statement is requesting default SUM statistic for VAR variable first and Tot (any VAR not specifically assigned a request gets SUM).

So there is a conflict between what the Mean and N do when crossing the implied SUM.

You may have meant for First and Tot to be class variables if want a summary for each level of First  and Tot within ExamTitle values.

 

It helps to provide raw input data and what the result is expected to look like. Columns in Proc Tabulate are expected to be the summary of a single variable/statistic combination. Only the CLASS variables nest. So you won't be able to have a row title %passing in the same column as the n statistic, which what your pasted result looks like.

You may need to paste from a different source as the forum main windows will reformat things and what we see may not be what you pasted.

 

Sometimes you have to presummarize the data before displaying the values with Proc Print/tabulate/or report.

daisy6
Quartz | Level 8

The table I showed changed when posted online. It should be like that. That is the table I want.

the data are like s


Capture.PNGdata.PNG
daisy6
Quartz | Level 8
I used your method which treat first and tot as class variables instead of var. The code is
proc tabulate data=tt;
var pass;
class examtitle age first tot;
table age*pass*(mean n), examtitle*(first tot);
run;
the table created but has one column first=0 which I do not want. Thanks a lot anyway!

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!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

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