When it comes to Simulation using the ranexp function, what would I do if the exponential distribution is greater than 1? For example when I use the following code the output produced is a blank table:
data list1;
do i=1 to 50;
between=.4*ranexp(1.2);
serve=.4*ranexp(1.2);
output list1;
end;
proc print data=list1;
run;
How would I get this to work and have an output produced? Any help would be much appreaciated.
Thanks.
The RANEXP() function is deprecated. And the parameter for the function is the SEED, which controls the random number stream not the function. Make sure to read the latest version of the docs.
This function is deprecated. The function is suitable for small samples and for applications that do not require a sophisticated random-number generator. It is not suitable for parallel and distributed processing. For more demanding applications, use the STREAMINIT subroutine and the RAND('Exponential') function.
The RAND() function however, does support the Exponential distribution with a scale parameter.
Oh, and just to close the loop the RANEXP() function takes integer parameters which is why 1.2 doesn't work. Try 2, 3 or 12.
Thanks for this.
I just tried this out and can see that all integers seem to work. However, I'm still struggling to know what function to use to be able to generate results with a 1.2 exponential distribution mean. I've seen the docs you've recommended but I'm struggling to make sense of them.
The function is exactly as I posted above, what part of that are you having difficulty with?
Post your new code if you're having issues and explain what new issues you now have.
This is the new code I tried to use to generate my results, but the between and serve columns still produce blank results.
You forgot the exponential part...in the formula.
Remember to check the documentation, and that each documentation has an example of how the function is used.
data list1;
do i=1 to 20;
between = 0.4 * Rand('exponential', 1.2);
serve = 0.4*Rand('exponential', 1.2);
output queue1; <- this is wrong and changed from your previous code. It needs to match what's on the data line;
end;
RUN; <- You're missing this, technically not needed, but what I'd consider good practice, especially as you learn;
proc print data=list1; <-You (tried to) output your results to Queu1, not list1?;
run;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.