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;
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;
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.
Is this what you mean: where admission='admit' and count>=10?
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
where ( admission='admit' and count>=10 ) or admission='readmit'
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.
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.