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)>;
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!
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.