The SAS Output Delivery System and reporting techniques

TABULATE: Making it vertical

Accepted Solution Solved
Reply
Contributor
Posts: 30
Accepted Solution

TABULATE: Making it vertical

Dear all, 

 

I am using the following code to create a 'nice" output of frequencies and % for several variables: 

 

PROC TABULATE DATA=PATH.survey_formatted MISSING ORDER=FORMATTED;
TITLE6;
TITLE7 J=CENTER HEIGHT=2 COLOR=grey 'Table 1. Demographic Characteristics of Participants';
CLASS sex agecat racecat location education_level ;
CLASSLEV sex agecat racecat location education_level 
/ STYLE=[cellwidth=3in asis=on];
TABLES (sex agecat racecat location education_level)*
(n*F=4.0 pctn='(%)'*F=pctfmt.)/MISSTEXT='0' RTS=10;

 

The output, however, looks like one long horizontal table with 1 row and multiple columns. I would like it to look more like a table with many rows and 3 columns: variable name, Freq, % : 

 

---------| N     |    %   |

sex       |         |          |

   M      | 20    |  10% |

   F       | 180  | 90%  |

-------------------------

race       |

   White  |

   AA      |

   Asian  |

   Other  | 

 

How can it be done? Thank you very much. 

 

Julia


Accepted Solutions
Solution
‎02-25-2016 12:41 AM
Super User
Posts: 11,343

Re: TABULATE: Making it vertical

Try

PROC TABULATE DATA=PATH.survey_formatted MISSING ORDER=FORMATTED;
   TITLE6;
   TITLE7 J=CENTER HEIGHT=2 COLOR=grey 'Table 1. Demographic Characteristics of Participants';
   CLASS sex agecat racecat location education_level ;
   CLASSLEV sex agecat racecat location education_level 
      / STYLE=[cellwidth=3in asis=on];
   TABLES sex agecat racecat location education_level,
          n*F=4.0 pctn='(%)'*F=pctfmt.
         /MISSTEXT='0' RTS=10;
run;

The tabulate tables statement uses a Comma to delineate page, row, column. If there is no comma then the request is treated as column; one comma means row then column, 2 commas the first is page, then row then column.

 

     tables page variables,

                row values,

                column values

                /

     ;

View solution in original post


All Replies
Solution
‎02-25-2016 12:41 AM
Super User
Posts: 11,343

Re: TABULATE: Making it vertical

Try

PROC TABULATE DATA=PATH.survey_formatted MISSING ORDER=FORMATTED;
   TITLE6;
   TITLE7 J=CENTER HEIGHT=2 COLOR=grey 'Table 1. Demographic Characteristics of Participants';
   CLASS sex agecat racecat location education_level ;
   CLASSLEV sex agecat racecat location education_level 
      / STYLE=[cellwidth=3in asis=on];
   TABLES sex agecat racecat location education_level,
          n*F=4.0 pctn='(%)'*F=pctfmt.
         /MISSTEXT='0' RTS=10;
run;

The tabulate tables statement uses a Comma to delineate page, row, column. If there is no comma then the request is treated as column; one comma means row then column, 2 commas the first is page, then row then column.

 

     tables page variables,

                row values,

                column values

                /

     ;

Contributor
Posts: 30

Re: TABULATE: Making it vertical

Thank you very much! It did the trick. I am sorry for not thanking you for a while. Just had to postpone this project and came back to it only today. Thank you again!
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 460 views
  • 1 like
  • 2 in conversation