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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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