BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
turcay
Lapis Lazuli | Level 10

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

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

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

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

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 🙂

turcay
Lapis Lazuli | Level 10

Then like this->

 

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

?

PeterClemmensen
Tourmaline | Level 20

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;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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