Hello programmers,
I am trying to implement this piece of code from a SAS guide. I can't implement it as it's giving me error messages.
Can anyone explain why it doesn't work?
l=t(root(eps)); /* calculate cholesky root of cov matrix eps */
z=normal(j(1,n,seed)); /* generate n samplesize normals */
xx=l*z*v; /* multiply by cholesky root and variance */
tx=t(xx);
do i=1 to &n ;
Group[i] = round(ranuni(int(time())));
x[i] = rannor(int(time()))*2 ;
do r=1 to &mm ;
b0[r]=-.2-2.6*cos((r-&m)*3.14159/ 30)* / );
yy[i,r]=b0[r]*Group[i]+3.5*sin(2*3.14159*x[i]/5);
end;
end;
yy=yy+tx; /*yy with multivariate normal error*/
Thanks
Start by using
PROC IML;
as the first line of the program. Then you need to define the covariance matrix, eps. You can either read it from a SAS data set into a matrix or you can input it manually:
proc iml;
eps = {
9 3 1,
3 4 1.3,
1 1.3 2};
...
The comment mentions a matrix. Are you sure this is data step code, and not rather part of a proc iml?
Otherwise, it may be you are missing a custom function definition.
It is IML code , not Data step .
You need SAS/IML module . Calling @Rick_SAS
Start by using
PROC IML;
as the first line of the program. Then you need to define the covariance matrix, eps. You can either read it from a SAS data set into a matrix or you can input it manually:
proc iml;
eps = {
9 3 1,
3 4 1.3,
1 1.3 2};
...
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.