filtering data set using proc freq count

Reply
Contributor
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: 860

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;

Contributor
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:

DIAGNOSIS_PRIN_CDFrequencyDIAGNOSIS_PRIN_CDFrequencyV300032677V3001211094861568338910455V300032677V30012110948615683389104557778279153767218615

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.

Respected Advisor
Posts: 4,927

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;

quit;

PG

PG
Ask a Question
Discussion stats
  • 3 replies
  • 830 views
  • 0 likes
  • 3 in conversation