Hello,
I am hoping to figure out frequency of a categorical outcome by 2 other categorical variables.
Rates of HTN by education and income
I want it to look like this
Frequency of HTN
Education | Income | ||
<12 | Low | Middle | High |
12 |
|
|
|
12+ |
|
|
|
Untested, in the absence of sample data in the form of a working DATA step:
proc tabulate data=data1;
class educ income HTN;
tables educ * (HTN *(n pctn<htn>*f=pctf.))
, (income all);
run;
We don't know what HTN is. But more importantly, we need to see how your raw data is arranged. Some data set arrangements make this easy, other arrangements take a bit of extra programming to get the desired table. So please show us a portion of your actual (or fake) data in its actual arrangement, but this is important — you must provide the data as working SAS data step code (examples and instructions).
Hi Thank you for your response.
I think I figured out the structure of the code using proctab.
HTN is categorical - yes = 1 and no =0
proc format;
picture pctf (round) other = '009.9%';
run;
proc tabulate data=data1;
class educ income HTN
tables educ * (HTN *(n pctn*f=pctf.)), (income all);
run;
BUT I want the frequency of HTN (as an outcome) PER education category (i.e. column percentage but for each category of education) -- pctn or colpctn give me the percentage or column percentage for ALL the education categories.
Untested, in the absence of sample data in the form of a working DATA step:
proc tabulate data=data1;
class educ income HTN;
tables educ * (HTN *(n pctn<htn>*f=pctf.))
, (income all);
run;
This worked, thank you so much!
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.