Hi,
I want to generate a data set. What i want to learn is the SAS commands to do this; the specifics i describe are not the focus per se. I want to add that i know how to do this in spss and there, as is true here, the issue is the commands.
That said. Let's say i want to create 20000 records with each record having four variables: record number (_N_ ??), x1, a draw from a normal distribution with a mean of 3 and an SD of 2; x2, a draw from a uniform distribution with a range of 2 to 5 and y, the resulting value of this regression equation y = 3.0 + 2.0*x1 + 4.0*x2+err
where err equals a draw from a normal distribution with a mean of 0 and an SD of 1.5.
I expect that this is a trivially simple thing to do; i need to know the commands and how those commands are located in a data xxx1; set ??used??; run; code block.
Thanks, Gene Maguin
data want;
do record_number=1 to 20000;
x1=rand('normal',3,2);
...
output;
end;
run;
I leave the code to calculate X2 and Y to you as a homework assignment. Please see the RAND() function documentation for other random number generation options.
data want;
do record_number=1 to 20000;
x1=rand('normal',3,2);
...
output;
end;
run;
I leave the code to calculate X2 and Y to you as a homework assignment. Please see the RAND() function documentation for other random number generation options.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.