BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ybz12003
Rhodochrosite | Level 12

Hello,

Could anyone explain the code below?  Thanks much.

proc tabulate data=have;
class form site;
table form all, site*n='No. of flags'*f=5. all*f=5.;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

There is one comma there.  So the first part is the rows definition and the second part the columns definition.

For the rows you are saying make a row for each distinct value of FORM and a separate row for all of the data.

For the columns part you are saying make a column for each value of SITE and a separate column for all of the data.

Under the site columns you want to show the number of observations, you want the column header to be the given string and you want the counts to be displayed using the 5. format.

For the ALL column you also want the count (the default statistic) and you also want it displayed using 5 places.

 

 

It might just be easier to use PROC FREQ instead.  You can add the options the remove the percentages and end you with the same thing.

proc tabulate data=sashelp.class;
  class sex age;
  table age all,sex all;
run;

proc freq data=sashelp.class;
  tables age*sex /nopercent norow nocol ;
run;

View solution in original post

6 REPLIES 6
ybz12003
Rhodochrosite | Level 12

Mainly, I don't understand is table command part.

table form all, site*n='No. of flags'*f=5. all*f=5.;
Tom
Super User Tom
Super User

There is one comma there.  So the first part is the rows definition and the second part the columns definition.

For the rows you are saying make a row for each distinct value of FORM and a separate row for all of the data.

For the columns part you are saying make a column for each value of SITE and a separate column for all of the data.

Under the site columns you want to show the number of observations, you want the column header to be the given string and you want the counts to be displayed using the 5. format.

For the ALL column you also want the count (the default statistic) and you also want it displayed using 5 places.

 

 

It might just be easier to use PROC FREQ instead.  You can add the options the remove the percentages and end you with the same thing.

proc tabulate data=sashelp.class;
  class sex age;
  table age all,sex all;
run;

proc freq data=sashelp.class;
  tables age*sex /nopercent norow nocol ;
run;
ybz12003
Rhodochrosite | Level 12
what's 5. format?
Tom
Super User Tom
Super User

@ybz12003 wrote:
what's 5. format?

That is the normal numeric format with a width of 5 characters.

ybz12003
Rhodochrosite | Level 12
Make sense, thanks much!
data_null__
Jade | Level 19

 

 

TABLE <<page-expression,> row-expression,>
column-expression </ table-option(s)>;

 

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 919 views
  • 2 likes
  • 3 in conversation