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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
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

1 REPLY 1
Ksharp
Super User
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;


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