Programming the statistical procedures from SAS

need help for PROC TABULATE

Reply
Occasional Contributor
Posts: 9

need help for PROC TABULATE

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!

Respected Advisor
Posts: 4,770

Re: need help for PROC TABULATE

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.

Grand Advisor
Posts: 10,062

Re: need help for PROC TABULATE

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.

Occasional Contributor
Posts: 9

Re: need help for PROC TABULATE

[ Edited ]

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

the data are like s

Attachment
Attachment
Occasional Contributor
Posts: 9

Re: need help for PROC TABULATE

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!
Ask a Question
Discussion stats
  • 4 replies
  • 94 views
  • 0 likes
  • 3 in conversation