Simulate normal data for HLM

Reply
Frequent Learner
Posts: 1

Simulate normal data for HLM

I'm new to SAS and I have never simulated data before. For a project that I am currently working on, I'd like to simulate a normal and non-normal dataset for analysis with a simple hierarchical linear model. I would like to be able to compare the true parameters of the simulated datasets with the parameter estimates I calculate through analysis. I have read a lot of answers on this website and on others, but I still do not know how to proceed. Can anyone please point me in the right direction, or perhaps give me an example? I have no code to share because I do not know how to write it for the problem that I am trying to solve.

 

Thank you.

Frequent Contributor
Posts: 102

Re: Simulate normal data for HLM

To compute a normal random variable you can use the following:

data sim;
do i=0 to <N>;
NormalVar = &Mean + &STD*rannor(<seed>);
output;
end;
run;

Replace <N> with the number of cases you desire and <seed> with some number for reproducibility of your results. You can assign any values you please to macro variables &Mean and &STD. Both of them are optional and, if you don't use them, your random variable will have mean=0 and STD=1.

You can then take a log, exponentiate or do some other transformation to make your normal variable be not normal.
Grand Advisor
Posts: 9,584

Re: Simulate normal data for HLM


Post it at IML forum, since it is about data simulation. Rick is there.


SAS Super FREQ
Posts: 3,415

Re: Simulate normal data for HLM

If you have never simulated data before, you might start by reading the paper "Ten tips for simulating data with SAS."

 

Ask a Question
Discussion stats
  • 3 replies
  • 169 views
  • 1 like
  • 4 in conversation