DATA Step, Macro, Functions and more

How to - Get the Remaining two Sample by Using Proc Surveyselect?

Accepted Solution Solved
Reply
Super Contributor
Posts: 395
Accepted Solution

How to - Get the Remaining two Sample by Using Proc Surveyselect?

Hello everyone,

 

I can get sample of data when I use the Proc Surveyselect procedure but I can just one part of sample I want to get both part of data being sample data set.

 

I have a sample data as below(I'm just created) When use Proc SurveySelect procedure I can get %75 of data I also want to get the remaining %25 as data set.

 

Can somebody help me, please?

 

Data Have;
Length ID 8 Target 8;
Infile Datalines Missover;
Input ID Target;
Datalines;
1 1
2 0
3 1
4 0
5 1
6 1
7 1
8 1
9 0
10 1
11 0
12 0
13 1
14 0
15 0
;
Run;

Proc Surveyselect Data=Have 
	Out=Want1
	Method=Srs
	Rate=%Sysevalf(75/100);
Run;

Thank you


Accepted Solutions
Solution
‎02-02-2017 06:22 PM
PROC Star
Posts: 732

Re: How to - Get the Remaining two Sample by Using Proc Surveyselect?

yes that would work, or more compactly:

 

data out_75 out_25;
   set want1;
   if selected = 1 then output out_75;
   else output out_25;
run;

View solution in original post


All Replies
PROC Star
Posts: 732

Re: How to - Get the Remaining two Sample by Using Proc Surveyselect?

If I understand your question correctly, you can use the outall option to achieve this, by writing your code as

 

Data Have;
Length ID 8 Target 8;
Infile Datalines Missover;
Input ID Target;
Datalines;
1 1
2 0
3 1
4 0
5 1
6 1
7 1
8 1
9 0
10 1
11 0
12 0
13 1
14 0
15 0
;
Run;

Proc Surveyselect Data=Have 
	Out=Want1 outall
	Method=Srs
	Rate=%Sysevalf(75/100);
Run;

, and then splitting up the want1 dataset by the selection indicator variable that now appears in your data Smiley Happy

Super Contributor
Posts: 395

Re: How to - Get the Remaining two Sample by Using Proc Surveyselect?

Then like this->

 

DATA out_75;
 set Want1(where=(Selected=1));
run;
DATA out_25;
 set Want1(where=(Selected=0));
run;

?

Solution
‎02-02-2017 06:22 PM
PROC Star
Posts: 732

Re: How to - Get the Remaining two Sample by Using Proc Surveyselect?

yes that would work, or more compactly:

 

data out_75 out_25;
   set want1;
   if selected = 1 then output out_75;
   else output out_25;
run;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 143 views
  • 0 likes
  • 2 in conversation