BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bretthouston
Obsidian | Level 7

I am trying to subset data based on the frequency of a given value within a variable. I've attached a screen shot of a proc freq table, and essentially I would like to include all CCIDummy values where row percent UpdtxStatus 'yes' >/=5%. 

 

I tried the following code, but the '%' results in a syntax error:

proc sql;
create table TEST as
select *
from work.CombiningProceduresDummyVariable
group by CCIdummy
having (UpdtxStatus='yes')ge 5%;
quit;

 

Thanks in advance!

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

You are right, I edited 2 secs before yours came through. Good catch!

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20

Hi @bretthouston   I think you may be looking to do this

 

proc sql;
create table TEST as
select *
from work.CombiningProceduresDummyVariable
group by CCIdummy
having sum(UpdtxStatus='yes')/n(CCIdummy) ge .05;
quit;
Reeza
Super User
Mean for percentage that's greater than 0.05, or the denominator should be the count of updtxstatus not 100.
novinosrin
Tourmaline | Level 20

You are right, I edited 2 secs before yours came through. Good catch!

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 2263 views
  • 3 likes
  • 3 in conversation