Getting certain percentage for items in a dataset

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 15
Accepted Solution

Getting certain percentage for items in a dataset

I've the below data. If an item from the below dataset, is more thatn 10% of the whole items, I want it separate bucket. Thanks.

ITEM
apples
apples
tomotos
tomotos
peppers
peppers
xyz
abc
xyz
abc
abc
xyz
abc
xyz
abc
tuv
tuv
tuv
tuv
abc
xyz
tuv

Accepted Solutions
Solution
‎03-24-2017 10:42 PM
Valued Guide
Posts: 947

Re: Getting certain percentage for items in a dataset

PROC FREQ will do what you need.  It usually prints frequencies and percents, but you can also ask for an output dataset, which can then be filtered through a "where=(percent>=10)" condition:

 

 

proc freq data=have noprint;

  tables item / out=want (where=(precent>=10));

run;

View solution in original post


All Replies
Valued Guide
Posts: 947

Re: Getting certain percentage for items in a dataset

Your question illustrates to me why we constantly ask folks to show not only the input data, but show what the output should look like.

 

It's apparent that you want to do something for each values that accounts for more than 10% of the total.   That part's quite easy.

 

But what do you mean by "separate bucket"?  A new data set?  A "bucket" for each value passing the criterion?  Or a single "bucket for all of those values?

 

The less mind reading required, the better will be the answers.

Occasional Contributor
Posts: 15

Re: Getting certain percentage for items in a dataset

Thanks for the suggestion. Wish I would have more illustrated.

 

Let's say if I have to have generate below output dataset. I don't want items which are less than 10%.  Thank you.

 

Item Percentage
abc13%
tuv11%
apples13%
Solution
‎03-24-2017 10:42 PM
Valued Guide
Posts: 947

Re: Getting certain percentage for items in a dataset

PROC FREQ will do what you need.  It usually prints frequencies and percents, but you can also ask for an output dataset, which can then be filtered through a "where=(percent>=10)" condition:

 

 

proc freq data=have noprint;

  tables item / out=want (where=(precent>=10));

run;

Occasional Contributor
Posts: 15

Re: Getting certain percentage for items in a dataset

Thank you Sir.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 137 views
  • 0 likes
  • 2 in conversation