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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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