BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
braverju
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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

2 REPLIES 2
ballardw
Super User

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

                /

     ;

braverju
Obsidian | Level 7
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!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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