BookmarkSubscribeRSS Feed
thanoon
Calcite | Level 5

hi all

i need your help to simulate multivariate normal data with 10 var. when i  run this code i receive errors .

%let N = 1000;                               /* size of each sample */

/* Multivariate normal data */

proc iml;

/* specify the mean and covariance of the population */

Mean = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

Cov = {32.0897 13.1740 -4.8130 -2.9651 6.0853 2.2018 2.6580 3.4379 -1.8501 -7.4523

       13.1740 18.3444 -5.2602 -9.4638 3.0731 2.1855 3.9010 3.0226 -3.5204 -4.3176

      -4.8130 -5.2602 7.7173 2.1597 -0.3544 -3.3951 -0.7576 -2.9107 5.3209 5.5138

      -2.9651 -9.4638 2.1597 20.1232 1.1670 0.8156 -12.3116 -2.4223 5.5468 2.1305

       6.0853 3.0731 -0.3544 1.1670 3.8644 0.6464 0.5127 0.9321 -0.3289 -1.9678

       2.2018 2.1855 -3.3951 0.8156 0.6464 7.8445 2.9060 -1.2132 -4.2227 -5.0253

       2.6580 3.9010 -0.7576 -12.3116 0.5127 2.9060 14.5232 1.7516 -4.8958 1.2902

       3.4379 3.0226  -2.9107 -2.4223 0.9321 -1.2132 1.7516 6.6480 -0.7609 2.7944

      -1.8501 -3.5204 5.3209 5.5468 -0.3289 -4.2227 -4.8958 -0.7609 7.9543 5.7160

      -7.4523 -4.3176 5.5138 2.1305 -1.9678 -5.0253 1.2902 2.7944 5.7160 16.1720};

call randseed(4321); 

X = RandNormal(&N, Mean, Cov);               /* 1000 x 10 matrix     */

/* check the sample mean and sample covariance */

SampleMean = mean(X);                        /* mean of each column */

SampleCov =  cov(X);                         /* sample covariance   */

/* print results */

c = "x1":"x10";

print (X[1:,1000]);

print SampleMean[colname=c];

print SampleCov[colname=c rowname=c];

/* write SAS/IML matrix to SAS data set for plotting */

create MVN from X[colname=c];  append from X;  close MVN;

quit;

1 REPLY 1
thanoon
Calcite | Level 5

hi all

i solved this problem, i forget the comma for covariance matrix.

regards

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

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 1 reply
  • 1444 views
  • 0 likes
  • 1 in conversation