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

I am working on a predictive model with a sample size of about 430K, of which the target is binary.  The rare event (1) has about 1000 samples. I need to come up with a way so that the ratio is about 50%. Currently I only have access to SAS Enterprise Guide. 

 

What are some recommendations on how to handle this with sample code?

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

You want oversample as ratio 1:1 ?

 

data class;
 set sashelp.class;
run;
proc sort data=class;
by sex;
run;
proc surveyselect data=class out=want sampsize=(5 5) seed=12345678;
strata sex;
run;

View solution in original post

5 REPLIES 5
Reeza
Super User

Which Task/Proc are you using? I'm assuming Logistic regression but depends partially on your variables.

 

If you define your model/proc you can find full examples in the SAS documentation for that procedure.

PGStats
Opal | Level 21

Use proc surveyselect, stratify by your target variable, and request sampling rates of 1 and 1/430 for your target and non target strata, respectively.

PG
ballardw
Super User

@PGStats wrote:

Use proc surveyselect, stratify by your target variable, and request sampling rates of 1 and 1/430 for your target and non target strata, respectively.


 

Or instead of sample rate you can specify an exact sample size. If you request 100 from reach strata your sample will be half of one and half of the other.

It is helpful to know that Surveyselect will provide both the selection probability and the sampling weight for each record.

Ksharp
Super User

You want oversample as ratio 1:1 ?

 

data class;
 set sashelp.class;
run;
proc sort data=class;
by sex;
run;
proc surveyselect data=class out=want sampsize=(5 5) seed=12345678;
strata sex;
run;
Sth19
Calcite | Level 5

I do want to oversample as a 1:1 ratio.

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
  • 5 replies
  • 689 views
  • 0 likes
  • 5 in conversation