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-2024.png

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.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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