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;
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;
Mainly, I don't understand is table command part.
table form all, site*n='No. of flags'*f=5. all*f=5.;
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 wrote:
what's 5. format?
That is the normal numeric format with a width of 5 characters.
TABLE <<page-expression,> row-expression,>
column-expression </ table-option(s)>;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.