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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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