Xia.Song
Xia.Song

Reputation: 426

Make the output of proc tabulate to vertical?

My SAS code is as follow:

DATA CLASS;
INPUT NAME $ SEX $ AGE HEIGHT WEIGHT;
CARDS;
ALFRED  M  14  69.0 112.5
ALICE   F  13  56.5  84.0
BARBARA F  13  65.3  98.0
CAROL   F  14  62.8 102.5
HENRY   M  14  63.5 102.5
RUN;
PROC PRINT;
    TITLE 'DATA';
RUN;
proc print data=CLASS;run;

proc tabulate data=CLASS;
    var AGE HEIGHT WEIGHT;
    table (AGE HEIGHT WEIGHT)*(MEAN STD MEDIAN Q1 Q3 MIN MAX n NMISS);
    title 'summary';
run;

The out put looks like

enter image description here

How can make the output list in the vertical direction?

Upvotes: 3

Views: 813

Answers (1)

Richard
Richard

Reputation: 27508

A TABLE statement without a comma (,) is specifying only a column expression.

Use a comma in your table statement

table <row-expression> , <column-expression> ;

Example:



DATA CLASS;
INPUT NAME $ SEX $ AGE HEIGHT WEIGHT;
CARDS;
ALFRED  M  14  69.0 112.5
ALICE   F  13  56.5  84.0
BARBARA F  13  65.3  98.0
CAROL   F  14  62.8 102.5
HENRY   M  14  63.5 102.5
;

ods html file='tabulate.html' style=plateau;

TITLE 'DATA';
proc print data=CLASS;
run;

proc tabulate data=CLASS;
    var AGE HEIGHT WEIGHT;

    table (AGE HEIGHT WEIGHT)*(MEAN STD MEDIAN Q1 Q3 MIN MAX n NMISS);

    * comma being used;
    table (AGE HEIGHT WEIGHT),(MEAN STD MEDIAN Q1 Q3 MIN MAX n NMISS);

    * comma being used, swapping row and column expressions;
    table (MEAN STD MEDIAN Q1 Q3 MIN MAX n NMISS),(AGE HEIGHT WEIGHT);

    title 'summary';
run;

enter image description here

Upvotes: 3

Related Questions