BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
chrkim
Calcite | Level 5

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+

 

 

 

 

@sasasf 

1 ACCEPTED SOLUTION

Accepted Solutions
mkeintz
PROC Star

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;
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

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

--
Paige Miller
chrkim
Calcite | Level 5

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. 

 

mkeintz
PROC Star

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;
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
chrkim
Calcite | Level 5

This worked, thank you so much! 

 

 

SAS Innovate 2025: Register Now

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 644 views
  • 0 likes
  • 3 in conversation