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/

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 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
  • 2303 views
  • 0 likes
  • 2 in conversation