BookmarkSubscribeRSS Feed
SASUSER97
Calcite | Level 5

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.

 

8 REPLIES 8
SASUSER97
Calcite | Level 5
When it comes to Simulation using the ranexp function, what would I do if the exponential distribution is greater than 1? For example an exponential distribution of 1.2 doesn't produce an Output because 1.2 > 1.
Reeza
Super User

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. 

http://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=p0fpeei0opypg8n1b06qe4r040lv.htm&...

x=RAND('EXPONENTIAL', <σ>)

Reeza
Super User

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. 

 

 

SASUSER97
Calcite | Level 5

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.

Reeza
Super User

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.

SASUSER97
Calcite | Level 5

This is the new code I tried to use to generate my results, but the between and serve columns still produce blank results.

 

data list1;
do i=1 to 20;
between=.4*Rand(1.2);
serve=.4*Rand(1.2);
output queue1;
end;
proc print data=list1;
run;
 
I know it's probably a mistake I've made on my behalf but I can't seem to see where I've gone wrong. Once again thanks for your help.
 
 
Reeza
Super User

x=RAND('EXPONENTIAL', <σ>)

 

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;

 

 

 

SASUSER97
Calcite | Level 5
Thanks for all the help, it was extremely useful. I managed to figure out where I went wrong in the end and I've got it done now

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 848 views
  • 2 likes
  • 2 in conversation