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

I am trying to create different data sets on SAS with specifed variance/covariances on SAS university edition, but I am very unsure how to go about this. 

Thank you! 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Your trying to simulate data? If so read Rick Wicklins blog and/or book on simulating data in SAS. 

View solution in original post

4 REPLIES 4
Reeza
Super User

Your trying to simulate data? If so read Rick Wicklins blog and/or book on simulating data in SAS. 

as00502
Calcite | Level 5

I have used Rick Wilkins' method to simulate multivariate normal data with a set covaraince matrix. I am ultimately trying to carry out mixed model analysis on this data. I am unsure how to split it up into groups, as it is already split into 'x1'...'x4'. This is the code I am using, if you happen to have any ideas?

 

proc iml;
Mean = {1, 2, 3, 4};
Cov = {0.5 0 0 0, 0 0.5 0 0, 0 0 0.5 0, 0 0 0 0.5};
N = 1000;
call randseed(123);
X = RandNormal(N, Mean, Cov);
SampleMean = mean(X);
SampleCov = cov(X);
varNames = "x1":"x4";

print SampleMean[colname=varNames],
SampleCov[colname=varNames rowname=VarNames];
create MVN from X[colname=varNames];
append from X;
close MVN;
quit;

Rick_SAS
SAS Super FREQ

The example you show uses RANDNORMAL function to simulate correlated variables. Presumably you also want to generate correlated observations? The book Simulating Data with SAS covers mixed models in Chapter 12, pp. 230-242.  The article "Constructing common covariance structures" (from Chapter 10) shows some related computations.

PGStats
Opal | Level 21

You will need to specify the distribution as well. Check out the RAND() function.

PG

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 4 replies
  • 756 views
  • 0 likes
  • 4 in conversation