Author tip: How to sample efficiently in SAS

0

Contributed by Rick Wicklin, author of Statistical Programming with SAS/IML Software

This year at SAS Global Forum 2011, I am presenting a statistical tutorial, "Data Simulation for Evaluating Statistical Methods in SAS". In this course, I show how to create data with known properties (such as skewed or heavy-tailed) and how to use that data to understand when using a particular statistic is valid or invalid. For example, can you use the t test for data that are highly skewed?

During my presentation, I'll be sharing some tips and techniques from my book, Statistical Programming with SAS/IML Software. The following tip is particularly important for efficiently using SAS/IML software to generate samples.

Tip:
To generate N random samples from a specified distribution, allocate a vector of length N and call the RANDGEN subroutine.

For example, to generate 1,000 random numbers from the standard normal distribution, you can use the following statements:

proc iml;

x = j(1000, 1);            /** allocate 1000 x 1 vector **/

call randgen(x, "Normal"); /** sample from random normal **/

My book has more than 150 other tips and techniques that can help you use SAS/IML software more efficiently for data analysis, sampling and simulation, and writing statistical analyses.

Do you have any questions for Rick? Submit a comment here or look for Rick in the SAS/IML and SAS/IML Studio discussion forum. You can also find additional tips on Rick's popular blog The DO Loop

Share

About Author

Rick Wicklin

Distinguished Researcher in Computational Statistics

Rick Wicklin, PhD, is a distinguished researcher in computational statistics at SAS and is a principal developer of SAS/IML software. His areas of expertise include computational statistics, simulation, statistical graphics, and modern methods in statistical data analysis. Rick is author of the books Statistical Programming with SAS/IML Software and Simulating Data with SAS.

Comments are closed.

Back to Top