From the course: SAS Programming for R Users, Part 2

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Demo: The DO loop and random number generation

Demo: The DO loop and random number generation - SAS Tutorial

From the course: SAS Programming for R Users, Part 2

Demo: The DO loop and random number generation

- [Narrator] In this demonstration let's go ahead and generate some random data sets. In part A I'm going to create a data set called random and I'm going to drop the index variable i. I'm going to use this three minute subroutine to set a seed, and in the DO loop I'm going from i equals one to 10 to simulate 10 total values. So first I'm going to reproduce the rnorm function, using the rand function, specify the normal distribution, and the parameters here are mean of 20 and a standard deviation of five. Next, I'll reproduce the rbinom function, specify the binomial distribution, give it a probability of success of .25, and only one single trial. So in this case I'm generating Bernoulli data. Now if I wanted to generate a uniform distribution between the values of zero and 10, I'll simply use the rand function, specify the uniform distribution which only generates values between zero and one, and I'm going to multiply every value by 10. This gives me values between zero and 10. And…

Contents