Hi!
I have the following data
DATA HAVE;
input year dz area;
cards;
2000 1 08
2000 1 06
2000 1 06
;
run;
proc freq data=have;
table area*dz / norow nocol;
run;
I get the following output
I would like to format it to put frequency in one column and percent in another column (and I don't want the total column) rather than the default SAS output. Is there a way to do it?
Thank you!
I don't know how to get the expected output with proc freq. Proc tabulate could be used:
proc tabulate data=have;
class area;
var dz;
table area, dz*(n colpctn);
run;
I don't know how to get the expected output with proc freq. Proc tabulate could be used:
proc tabulate data=have;
class area;
var dz;
table area, dz*(n colpctn);
run;
Thank you, proc tabulate does the work but only for numeric variables. Can I use proc tabulate to get similar output if one of the variables is a character variable?
DATA HAVE;
input year dz $8. area;
cards;
2000 stroke 08
2000 stroke 06
2000 stroke 06
;
run;
when I use the code provided, it gives me: ERROR: Variable dz in list does not match type prescribed for this list.
Thank you!
Just move dz from the var statement into the class statement and remove the empty var statement.
@Priyamvada07 wrote:
Hi! I just realized when using proc tabulate I am missing the last row that is the 'total' as seen in my output image in the original question. Is there a way to retain the 'total' column?
Yes, of course using the "all" keyword in the tables-statement. Can't test it now, but the following code should work.
proc tabulate data=have;
class area;
var dz;
table area all, dz*(n colpctn);
run;
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.