Hi,
I am trying to simulate a dataset for 100 subjects over the course of 10 days such that the variable y with normal distribution is repeating the same value within each subject per each day.
I have the following:
data A;
call streaminit(1);
do subject =1 to 100;
do t = 1 to 10;
y=rand('normal',1,2);
output;
label t='Day';
end;
end;
run;
which produces:
subject day y
1 1 1.03
1 2 3.02
....
2 1 1.45
2 2 0.39
...
etc.
I want this structure:
subject day y
1 1 1.03
1 2 1.03
....
2 1 1.45
2 2 1.45
...
etc.
Any help is appreciated.
Thank you!
So you want a normal distribution accross subjects, but no variation at all within subject, right?
If so, then modify your program by taking the RAND function outside of the inner loop, and put it in the outer loop:
data A;
call streaminit(1);
do subject =1 to 100;
y=rand('normal',1,2);
do t = 1 to 10;
output;
end;
end;
label t='Day';
run;
So you want a normal distribution accross subjects, but no variation at all within subject, right?
If so, then modify your program by taking the RAND function outside of the inner loop, and put it in the outer loop:
data A;
call streaminit(1);
do subject =1 to 100;
y=rand('normal',1,2);
do t = 1 to 10;
output;
end;
end;
label t='Day';
run;
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: