- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
hi,
Does someone have suggestion code to offer on how I can assign a dummy variable (1 or 0) to identify a random sample from a population?
Say I have a population of 1,800 records and I want to flag exactly 35, randomly. The random sample volume will always remain the same. I want to retain the full 1,800 records, but with a column that can be filtered to, say, 1, to identify the random sample.
Thank you
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use the right procedure and this gets easy:
proc surveyselect data=yourdatasetgoeshere out=selected outall sampsize=35; run;
The OUTALL option says to output all records from input dataset and add a variable named SELECTED which has values 0/1 with 1 indicating those selected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use the right procedure and this gets easy:
proc surveyselect data=yourdatasetgoeshere out=selected outall sampsize=35; run;
The OUTALL option says to output all records from input dataset and add a variable named SELECTED which has values 0/1 with 1 indicating those selected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Here's a simple example using surveyselect (just 50 for the example). If you have the sort order the same on the frame and use the same seed, you'll keep the same sampled IDs every time you run it.
data frame;
do id = 1 to 50;
output;
end;
run;
proc surveyselect data = frame
method = srs
n = 35
out = sample outall;
run;