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

Hi,

It is a simple way to get random 100 row from your dataset.

HHCFX

proc sql outobs=100;
create table WANT as select * from HAVE order by ranuni(0);quit;

 

1 ACCEPTED SOLUTION

Accepted Solutions
hhchenfx
Rhodochrosite | Level 12

proc sql outobs=100; create table random as select * from a order by ranuni(0);quit;

View solution in original post

2 REPLIES 2
hhchenfx
Rhodochrosite | Level 12

proc sql outobs=100; create table random as select * from a order by ranuni(0);quit;

Rick_SAS
SAS Super FREQ

Specifically, this selects 100 rows WITHOUT REPLACEMENT. That is, the rows are unique.  In some applications, you might need other sampling schemes, such as selection WITH replacement. The SURVEYSELECT procedure is a general way to select rows from a data set. It supports many different sampling schemes: with replacement, without replacement, stratified sampling, and more.

 

See this article for a discussion and an example of ways to sample with replacement in SAS.

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

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
  • 2 replies
  • 1081 views
  • 0 likes
  • 2 in conversation