BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello,

I want to create a pseudo random data set from existing data. Basically, I have a primary data set (call it Alpha) and I want to generate a new dataset (Beta) with a random selection of lines from Alpha. The logic of the process is something like this:

1. Open Alpha.
2. Generate a random number variable in Alpha.
3. Select one line of data (row) from Alpha based on the random numbers.
4. Append this random line of data to Beta.
5. Repeat 1-4 in a loop for X repetitions to create Beta with X lines. (Random draw with possibility of repeated draws)

Is there a quick way to write a macro or proc sql to do this?

Thanks!
2 REPLIES 2
RickM
Fluorite | Level 6
I knew this was covered in the Advanced Certification Prep Guide and after a small amount of searching I found this site that shows (and explains) the code.

http://www.stat.psu.edu/online/program/stat482/11random/03random_sampling_with.html
Patrick
Opal | Level 21
In case you've got SAS\STAT: PROC SURVEYSELECT could do the job as well.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1322 views
  • 0 likes
  • 3 in conversation