BookmarkSubscribeRSS Feed
tmcrouse
Calcite | Level 5

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;

5 REPLIES 5
ballardw
Super User

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;

tmcrouse
Calcite | Level 5

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.

FloydNevseta
Pyrite | Level 9

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

tmcrouse
Calcite | Level 5

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

FloydNevseta
Pyrite | Level 9

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

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 1940 views
  • 0 likes
  • 3 in conversation