BookmarkSubscribeRSS Feed
amajeau
Fluorite | Level 6

Am I able to use an "if" command while generating a two-way table using proc freq? Say for example I have information on treatment versus control and gender, that is, male vs female and want to find out the proportion of males in treatment and the proportion of males in control. Is there a way to set my table statement to something like:

 

tables treatment * sex (if sex=1);

4 REPLIES 4
Reeza
Super User

WHERE not if, but it applies to the whole proc.

 

proc freq data=sashelp.class;

table age*sex;

where sex='F';

run;

 

You can also use a BY statement or just look at the column percents/totals in the PROC FREQ output. There are summaries for the overall table, for each row and column in the default output.

 

proc sort data=sashelp.class out=class; 

by sex;

 

proc freq data=class;

by sex;

table age*sex;

run;

 

amajeau
Fluorite | Level 6

Is this no longer applicable when using proc surveyfreq instead of just proc freq?

Reeza
Super User

@amajeau wrote:

Is this no longer applicable when using proc surveyfreq instead of just proc freq?


What's this? Your question said proc freq..

 

 

 

 

 

ballardw
Super User

With surveyfreq if you use the where clause you remove some information and really wouldn't want to have a table statement with

 

tables age*sex.

 

Are perhaps looking to do domain analysis of age? You may want to look at SURVEYMEANS and use a Domain Sex statement.

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
  • 14038 views
  • 4 likes
  • 3 in conversation