BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
karciamalino
Calcite | Level 5

Hello,

I have data with 156 variables and 10000 observations. Values of one variable are from 2 to 16 (only even) and I need to select 4 randomly selected values from this variable and keep them in data. I tried to use surveyselect procedure, but it doesn't work. I also thought about using ranuni, but don't know how to create even number:(

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Here is an example of selecting 4 age groups from sashelp.class with proc surveyselect:

 

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

proc surveyselect data=class out=ageSample sampsize=4;
cluster age;
run;
PG

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

Clarification is requested. When you say:

 

I need to select 4 randomly selected values

 

do you really mean "select 4 randomly selected observations"?


Can you give us an example using, say, a data set with 20 observations, and the desired output?

--
Paige Miller
karciamalino
Calcite | Level 5

Here is the example data. I want ot select these observations with for example a=2 or 4 or 6 or 8, the I don't know the value and I want to get the random one from available.

example.JPG

and desired output in my example with a=2,4,6,8 would be observations 1,2,3,4,5,6,7,8,9,10,12,13,16.

 

PGStats
Opal | Level 21

Here is an example of selecting 4 age groups from sashelp.class with proc surveyselect:

 

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

proc surveyselect data=class out=ageSample sampsize=4;
cluster age;
run;
PG
karciamalino
Calcite | Level 5

That is what I meant, thanks a lot! 😄

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 3017 views
  • 0 likes
  • 3 in conversation