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

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
1 ACCEPTED SOLUTION

Accepted Solutions
mkeintz
PROC Star

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;

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

View solution in original post

4 REPLIES 4
mkeintz
PROC Star

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.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
West26
Obsidian | Level 7

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%
mkeintz
PROC Star

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;

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
West26
Obsidian | Level 7
Thank you Sir.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 4 replies
  • 454 views
  • 0 likes
  • 2 in conversation