filtering data set using proc freq count

Posts: 42

filtering data set using proc freq count

I'm fairly new to SAS but was wondering if there is a way to delete observations by frequency count?  For example, I used proc freq to generate a count of all diagnosis codes but all frequency counts<=5, I want to remove from the dataset.  Is this possible?

Valued Guide
Posts: 863

Re: filtering data set using proc freq count

There's going to be a lot of different ways to get this result.  One way is to use the out= statement in your proc freq.  This will get you a dataset with the result that you can manipulate anyway you want:

proc freq data= have;table variable /out=want;

Posts: 42

Re: filtering data set using proc freq count

Posted in reply to Steelers_In_DC

For example,

I have over 500,000 observations in this dataset.

I already have my data filtered for the columns I need but for the diagnosis column, I ran a proc freq.

My Proc Freq data looks like:


I want to suppress or result any diagnosis code that has a frequency count <=5 with Blank or '.'

I am thinking about creating a data step and using IF-THEN statements to accomplish this task but it will be very time consuming.

Esteemed Advisor
Posts: 5,337

Re: filtering data set using proc freq count

proc freq might not be the best tool for data management. I would use proc SQL :

proc sql;

create table want as

select * from have

group by diagnosisCode

having count(*) > 5;



Ask a Question
Discussion stats
  • 3 replies
  • 3 in conversation