Help using Base SAS procedures

Where Possible in Proc Freq

Reply
Contributor
Posts: 69

Where Possible in Proc Freq

Is where possible in Proc Freq statement?

This is my code and I want it to have a where admit >=10

PROC FREQ DATA = ReAdm.CHI2 ORDER = DATA; BY COMPARISON;

WEIGHT COUNT;

TABLES SVRTY_LVL_CD*WHO*ADMISSION/CMH EXPECTED OUTEXPECT;

EXACT OR;

OUTPUT OUT = ReAdm.Final3 OR CMH;

RUN;

If I could say maybe after the weight count;

PROC FREQ DATA = ReAdm.CHI2 ORDER = DATA; BY COMPARISON;

WEIGHT COUNT;

where (admission ='admit' >=10);

TABLES SVRTY_LVL_CD*WHO*ADMISSION/CMH EXPECTED OUTEXPECT;

EXACT OR;

OUTPUT OUT = ReAdm.Final3 OR CMH;

RUN;

Super User
Posts: 10,516

Re: Where Possible in Proc Freq

Yes, WHERE statements will work in PROC FREQ. Also the order of statements such as WEIGHT , WHERE and FORMAT do not matter in PROC FREQ (or most other procs).

However the example you show would always be false. The comparison in left to right of Admission = 'admit' will return either 0 for false or 1 for true. neither would be >= 10. The parentheses are only needed when forcing groups in the comparison.

If you are trying to compare the variable ADMISSION and some other value it might look like this:

WHERE admission = 'admit' and TicketPrice >=10;

Contributor
Posts: 69

Re: Where Possible in Proc Freq

Well the admission column has the informatin of readmit and admit. The count has the count of the readmit and the admit. I need the readmit to return but i only want the readmits and admits if the admits are >=10.

Frequent Contributor
Posts: 101

Re: Where Possible in Proc Freq

Is this what you mean:  where admission='admit' and count>=10?

Contributor
Posts: 69

Re: Where Possible in Proc Freq

Partially but it needs to return the information in the admission column that is also ='readmit'

PROC FREQ DATA = ReAdm.CHI2 ORDER = DATA; BY COMPARISON;

WEIGHT COUNT;

where admission='admit' and count>=10;

TABLES SVRTY_LVL_CD*WHO*ADMISSION/CMH EXPECTED OUTEXPECT;

EXACT OR;

OUTPUT OUT = ReAdm.Final3 OR CMH;

RUN;

this returns only the admit portion of the admission columns. I have readmit and admit and want it to return all my readmits but only return those in conjunction with admit that is >=10

Frequent Contributor
Posts: 101

Re: Where Possible in Proc Freq

where ( admission='admit' and count>=10 ) or admission='readmit'

Ask a Question
Discussion stats
  • 5 replies
  • 203 views
  • 0 likes
  • 3 in conversation