Contributor
Posts: 44

# How do I combine systematic sampling and sample rate using proc surveyselect

How do I solve:  select only every 6th observation.  sub-sample size should be 10% of original dataset size.

Below is a snippet of code for the 10% and every 6th observation.  How do I combine both every 6th observation and same size of 10% using the proc surveyselect or can you?

proc surveyselect data=datain samprate=10 out=dataout;

run;

proc surveyselect data=datain method=sys (interval=6) out=dataout;

run;

Posts: 5,474

## Re: How do I combine systematic sampling and sample rate using proc surveyselect

``````proc surveyselect data=datain method=sys (interval=6) out=dataout;
run;

/* Systematic sampling gives a sampling rate of 1/6.
To achieve an overall sampling rate of 10%,
the random sampling rate should be (1/10) / (1/6) = 0.6 */

proc surveyselect data=dataout samprate=0.6 out=want;
run;``````
PG
Super User
Posts: 23,224

## Re: How do I combine systematic sampling and sample rate using proc surveyselect

fpascal wrote:

Below is a snippet of code for the 10% and every 6th observation.  How do I combine both every 6th observation and same size of 10% using the proc surveyselect or can you?

You need to clarify your requirements.

Is it valid to just stack your two output datasets?

Or are you trying to combine the methodologies somehow?

Contributor
Posts: 44

## Re: How do I combine systematic sampling and sample rate using proc surveyselect

Item  2: Create a 10% sub-sample (find out the total number of observations in the data file and calculate 10% of this total number to determine the number of observations for your sub-sample) of the original data. Perform a Univariate statistical analysis on this sub sample for Systolic blood pressure and Diastolic blood pressure. Also, report 95% confidence interval for basic statistics.

Item 3: Create a sub-sample from the original dataset by selecting only every 6th observation (sub-sample size should be the same size as the sub-sample size of 10% of #2 above). Perform a Univariate statistical analysis on this sub-sample for Systolic blood pressure and Diastolic blood pressure. Also, report 95% confidence interval for basic statistics. Report the difference between #2 and #3 output.

I solved item 2 with the proc selectsurvey samprate=10 & proc univariate cibasic....

data assignment2q2;
infile'/folders/myfolders/Assignment2Dataset.txt' dlm='09'X end=eof;
input gender age systolic diastolic;

proc surveyselect data=assignment2q2 samprate=10 out=assignment2q2;
run;

proc univariate cibasic;
var systolic diastolic;
run;

it is item 3 where it appears to combine sample rate and method (interval).  My attempt is below but it is missing the 10% sample size of the original dataset

`data assignment2q3;	infile'/folders/myfolders/Assignment2Dataset.txt' dlm='09'X end=eof;	input gender age systolic diastolic;run;proc surveyselect data=assignment2q3 method=sys(interval=6) out=assignment2q3;run;proc univariate cibasic;	var systolic diastolic;run;`

Super User
Posts: 23,224

## Re: How do I combine systematic sampling and sample rate using proc surveyselect

@fpascal then Ksharp's solution should work for you.

Super User
Posts: 10,679

## Re: How do I combine systematic sampling and sample rate using proc surveyselect

Yeah. You need give us an example to clarify your question. Sample Data and Output .

``````data have;
set sashelp.cars;
run;

%let dsid=%sysfunc(open(have));
%let nobs=%sysfunc(attrn(&dsid,nlobs));
%let dsid=%sysfunc(close(&dsid));

%let n=%sysevalf(&nobs*0.1,i);

data want;
set have;
if mod(_n_,6)=0 then do;
n+1;
if n le &n then output;
end;
drop n;
run;
``````
Discussion stats
• 5 replies
• 480 views
• 2 likes
• 4 in conversation