Proc Freq "if" command

Reply
Occasional Contributor
Posts: 13

Proc Freq "if" command

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

Super User
Posts: 19,105

Re: Proc Freq "if" command

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;

 

Occasional Contributor
Posts: 13

Re: Proc Freq "if" command

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

Super User
Posts: 19,105

Re: Proc Freq "if" command


amajeau wrote:

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


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

 

 

 

 

 

Super User
Posts: 11,121

Re: Proc Freq "if" command

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.

Ask a Question
Discussion stats
  • 4 replies
  • 1017 views
  • 4 likes
  • 3 in conversation