Help using Base SAS procedures

Creating a sample design file for SURVEYSELECT

Reply
Contributor
Posts: 21

Creating a sample design file for SURVEYSELECT

NOTE that if Sample design file contains 0 for sampling rate of cells 6 and 8 these cells will not be in the output dataset.
I see 2 options:
1. Reset variable values, like I did for Spring segmentation but for ALL relevant sampling vars, in a separate data step.
2. Rejoin these records into the final file in a separate data step.

 

MY QUESTION IS: Is there a 3rd option?  Is there a way to indicate that I am NOT sampling from cells 6 and 8 and yet want all records from cells 6 and 8 to be included in the ouput dataset?

 

[I am using EG 7.1x connecting to an AIX 64 unix server with SAS 9.4 installed and SAS STAT v.??? (installed at same time as SAS 9.4)]

DATA SMPLDESIGN_&SSN.&SFY._&RD0 ;
INFILE DATALINES DELIMITER="," ;
INPUT BRAND $4. CELL _RATE_ ;
DATALINES ;
HAND,1,0.10
HAND,2,0.07
HAND,3,0.07
HAND,4,0.05
HAND,5,0.10
HAND,6,0.0
HAND,7,0.07
HAND,8,0.0
HAND,9,0.05
HAND,10,0.07
HAND,11,0.05
HAND,12,0.05
HAND,13,0.10
HAND,14,0.10
HAND,15,0.07
HAND,16,0.05
;
RUN ;

Esteemed Advisor
Posts: 5,535

Re: Creating a sample design file for SURVEYSELECT

Posted in reply to bbenbaruch

You could always use a trick like this:

 

proc sort data=sashelp.class out=class; by age; run;

data ss;
input age _rate_;
datalines;
11 50
12 50
13 50
14 0.00001
15 50
16 0.00001
;

proc surveyselect data=class samprate=ss out=temp outall outsize;
strata age;
run;

data sample;
set temp;
if SamplingRate < 0.0001 then Selected = 0;
run;

proc print; run;
PG
Contributor
Posts: 21

Re: Creating a sample design file for SURVEYSELECT

This may in fact be a good "work-around" solution,  

 

I would think that the "better" "work-around solution" would be to allow for the exclusion of strata with no sample selected in the PROC SURVEYSELECT output dataset and then merge these records back in.  Just as many steps -- but no danger of misleading values for sample-weights and selection probabilities in the final dataset.

 

However, I was hoping for a "real" solution that requires neither "gerrymandering" the data with an additional data step or having to merge unsampled strata back in.  I guess maybe I will just have to go away singing "You can't always get what you want."

Ask a Question
Discussion stats
  • 2 replies
  • 149 views
  • 1 like
  • 2 in conversation