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 - 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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
The DO loop6m 18s
-
(Locked)
Random number generation3m 40s
-
(Locked)
Demo: The DO loop and random number generation5m 27s
-
(Locked)
Plotting with the SGPLOT procedure6m 55s
-
(Locked)
Demo: Creating standard R plots7m 12s
-
(Locked)
Enhancing the plot1m 47s
-
(Locked)
Demo: Enhancing the plot5m 43s
-
(Locked)
Multi-cell plotting procedures and statements6m 5s
-
(Locked)
Demo: Multi-cell plotting4m 33s
-
-