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'

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

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