DATA Step, Macro, Functions and more

Stratified Random Sampling by Group

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 16
Accepted Solution

Stratified Random Sampling by Group

Hi,

 

I'd like to request some assistance with the following programming query.

 

I have an input dataset (please see attachement) - small sample provided below.  It consists of one row per person.  Each row belongs to a specific campaign cell and is given a model score (values from 1 - 10).

 

CellIndividualModelScore
100Person11
100Person22
100Person33
100Person44
100Person55
100Person66
100Person77
100Person88
100Person99
100Person1010
100Person111
100Person122
101Person133
101Person144
101Person155
101Person166
101Person177
102Person188
102Person199
102Person2010

 

For each value of Cell, I would like to perform a random stratified (strata variable: ModelScore) sample to split the data into 20 roughly equal-sized groups.  For example, the subset of rows that belong to cell 100 will be split into 20 groups, using the ModelScore variable. I would like this to be repeated for each value of Cell in the input dataset.

 

I was thinking of using PROC SURVEYSELECT with the GROUPS= option, but wasn't sure if there is a better approach. 

 

Many thanks,

 

Hoa


Accepted Solutions
Solution
‎03-15-2017 05:33 AM
Super User
Posts: 10,018

Re: Stratified Random Sampling by Group

Posted in reply to HoaTruong
What do you mean by " using the ModelScore variable. " ?
you want group it from smallest to largest ?

proc ranks data=have groups=20;
by cell;
var modelscore;
rank rank;
run;


View solution in original post


All Replies
Solution
‎03-15-2017 05:33 AM
Super User
Posts: 10,018

Re: Stratified Random Sampling by Group

Posted in reply to HoaTruong
What do you mean by " using the ModelScore variable. " ?
you want group it from smallest to largest ?

proc ranks data=have groups=20;
by cell;
var modelscore;
rank rank;
run;


☑ This topic is solved.

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

Discussion stats
  • 1 reply
  • 151 views
  • 2 likes
  • 2 in conversation