Note that this approach makes the endpoints of the range half as likely to be realized as the internal points.
Rick Wicklin's blog post looks at continuous ranges and integer ranges; here we have non-integer but discrete ranges.
RickM wrote:
Something like this would work.
var=round(ranuni(0)*(12.345+67.890),0.001)-12.345;
To generalize it you would need to create a macro or use proc fcmp.
See also my blog post, "How to generate random numbers in SAS."
Hi Rick! Do you a sample simulation code to generate multilevel data (nested data)? An example of this is a cluster-randomized trial (CRT) design where the treatment is implemented at the group level while the outcome is measured at the individual level?
Thanks,
Aye
There are examples like this in my book Simulating Data with SAS. For example, see Section 7.5 and Section 11.3.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.