Age Gender Ethnicity ..............................................
<=40 41-60 61-74 >=75 F M
n % n % n % n % n % n %
Partial
Complete
Total
All the variables are in a single dataset.
partial and complete are two values under a single variable in the same dataset
I Have the formats written for age and gender
Could anyone help me to build the code..please
Also i have similar other tables with columns to be added horizontally and they are present in the same dataset too
Are you looking for a statistical test or how to derive the table? And how does your data look?
PROC FREQ won't produce a table like you've shown and I'd recommend the other way anyways, ie partial/complete across the top and the variables down the side.
proc format;
value age_fmt
low - 13 = 'Pre-Teen'
13 - 19 = 'Teen'
20 - high='Adult';
value bmi_fmt
low - 18.5 = 'Underweight'
18.5 - 25 = 'Normal'
25 - 30 = 'Overweight'
30 - high = 'Obese';
run;
data class;
set sashelp.class;
bmi=(weight/height**2) * 703;
run;
proc tabulate data=class;
class age sex bmi;
table bmi, age*(n rowpctn='%') sex(n rowpctn='%');
format age age_fmt. bmi bmi_fmt.;
run;
Karun,
I suspect that your question is not how to get the data for the tables, but rather how to display it ranging across rather than in different tables.
To address the display, you need to use PROC TABULATE rather than FREQ. There are examples in the documentation on how to put multiple variables across the top.
Doc Muhlbaier
Duke
Are you looking for a statistical test or how to derive the table? And how does your data look?
PROC FREQ won't produce a table like you've shown and I'd recommend the other way anyways, ie partial/complete across the top and the variables down the side.
proc format;
value age_fmt
low - 13 = 'Pre-Teen'
13 - 19 = 'Teen'
20 - high='Adult';
value bmi_fmt
low - 18.5 = 'Underweight'
18.5 - 25 = 'Normal'
25 - 30 = 'Overweight'
30 - high = 'Obese';
run;
data class;
set sashelp.class;
bmi=(weight/height**2) * 703;
run;
proc tabulate data=class;
class age sex bmi;
table bmi, age*(n rowpctn='%') sex(n rowpctn='%');
format age age_fmt. bmi bmi_fmt.;
run;
Add all in where you need it. As an analyst you're allowed to suggest people do things differently in requests...its what defines a good analyst from a bad actually, IMO.
proc tabulate data=class;
class age sex bmi;
table bmi all, (age all)*(n rowpctn='%') (sex all)*(n rowpctn='%');
format age age_fmt. bmi bmi_fmt.;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.