BookmarkSubscribeRSS Feed
HM3
Calcite | Level 5 HM3
Calcite | Level 5

How to generate random var in a matrix (20*30) form having mean=3 and standard dev=1.

Thanks

Parth

1 REPLY 1
Rick_SAS
SAS Super FREQ

You don't specify the distribution, but I assume you want normally distributed values from N(3,1)? Here is a PROC IML solution:

proc iml;

x = j(20, 30);  /* allocate 20x30 matrix */

call randseed(123); /* seed random seed */

call randgen(x, "Normal", 3, 1); /* N(3,1) */

For more about generating random samples, see http://blogs.sas.com/content/iml/2010/09/22/efficient-sampling/

If you one day want a sample from a multivariate normal distribution, see http://blogs.sas.com/content/iml/2011/01/12/sampling-from-the-multivariate-normal-distribution/

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

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 2209 views
  • 0 likes
  • 2 in conversation