turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Data Management
- /
- Forum
- /
- Random Sample of a non-event

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-13-2014 04:35 PM

Hi All:

I am working on a logistic regression-- binary outcome. The 1 (or the event) has a sample size of 600, while the 0 (non-event) has a sample size of 8000.

How do I extract a random sample of 600 of the non-event? It seems like proc suveyselect only lets me take a random sample of all participants, not just those who fall in the non-event.

Thanks so much!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-13-2014 04:54 PM

On the input dataset name use the where option to select input records only for specific values. This completely subsets the data. The selection probability and weights will only work for that subset so be careful.

proc surveyselect data=lib.have (where=(eventvariable = 0)) ....

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-15-2014 01:12 PM

This code is not working. I keep getting an error message that says that my use of the where statement is incorrect.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-15-2014 02:48 PM

Post the code you're submitting

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-15-2014 02:52 PM

Hi,

Seems like trying to make a dataset containing equal number of event and non-event cases. Try this to get the desired sample dataset.

data sample;

set have;

if y=1 or (y=0 and ranuni(1234)<0.075) then output; /* Suppose y is the event variable */

run;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-15-2014 03:08 PM

When I used the code that you suggested, I got: data set has 0 observations and 1 variable.

I am trying to make a dataset containing an equal number of event and non-event cases.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-15-2014 03:09 PM

Thank you for all of your help!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-15-2014 04:14 PM

If you had clearly stated your need earlier then STRATA in survey select with event and nonevent sample sizes specified would have worked.