BookmarkSubscribeRSS Feed
grodman
Obsidian | Level 7

Hello - 

 

I'm producing an analysis in which I have to find the different combination of sample pools that will result in the most total subjects to available to study.  However, there are rules which govern how many subsets from each group I may take.  

 

For example... using the sample data below, I need to find the 5 combinations that will result in the most total people.  However, each combination must consist of hte following:

  • 1 subset from group A
  • 2 subsets from group B
  • 1 subset from group C

Is there a quick procedure/method to find this?

 

Note - in my real dataset, there are hundreds of subsets within each group.

 

Thanks!

 

 

data samples;
input group $ people;
datalines;
A 61
A 32
A 30
B 35
B 21
B 11
B 12
B 70
B 52
B 48
B 65
B 57
B 51
C 18
C 56
C 28
C 45
;;;;
run;

1 REPLY 1
PGStats
Opal | Level 21

Simply take the n highest from each group?

 

data samples;
input group $ people;
subset = _n_; /* unique subset number */
datalines;
A 61
A 32
A 30
B 35
B 21
B 11
B 12
B 70
B 52
B 48
B 65
B 57
B 51
C 18
C 56
C 28
C 45
;

data alloc;
input group $ subsets;
datalines;
A 1
B 2
C 1
;

proc sort data=samples; by group descending people;

data want;
merge alloc samples; by group;
if first.group then order = 0;
order + 1;
if order <= subsets then output;
drop order subsets;
run;

proc print data=want noobs; run;
PG

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 1121 views
  • 0 likes
  • 2 in conversation