BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ChuksManuel
Pyrite | Level 9

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?

ChuksManuel_0-1586739743263.png

 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

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

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};
 
...

View solution in original post

6 REPLIES 6
RichardDeVen
Barite | Level 11
And what are the errors ?
Kurt_Bremser
Super User

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.

Ksharp
Super User

It is IML code , not Data step .

You need SAS/IML module . Calling @Rick_SAS 

Rick_SAS
SAS Super FREQ

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};
 
...
ChuksManuel
Pyrite | Level 9
Thanks Dr Rick!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 568 views
  • 2 likes
  • 5 in conversation