Equivalent to R findInterval() function in SAS IML -


is there similar r's findinterval (or cut) in sas, in iml?

i'm converting r program of mine monte carlo simulations iml, , uses findinterval convert numbers random number generator output state. can write in iml replace it, it's terribly slow compared original. because findinterval takes advantage of compiled c code; there similar can use in sas?

are breaks uniform (equal probability) or not? uniform breaks, can use ceil(k*u) u vector or random uniform numbers. example, if want 10 observations randomly assigned numbers 1-4 equal probability, can say

y = ceil(4*ranuni(j(10,1))); 

or, if want use newer random number generator,

u = j(10,1); /** allocate **/ call randgen(u, "uniform"); /** fill u[0,1] **/ y = ceil(4*u); 

for unequal probability, use "table" distribution. example,

p = {0.1 0.5 0.2 0.2}; /** 4 categories given probabilities **/ y = j(10, 1);  call randgen(y, "table", p); /** fills 1-4 probability p **/ 

you might interested in using samplewithreplace module chapter 13 of book, statistical programming sas/iml software. can download code , see example of use @ http://blogs.sas.com/iml/index.php?/archives/75-hey!-those-two-people-have-the-same-initials!.html

both of these techniques eliminate need findinterval because produce categories directly. if really think need bin random numbers, can use algorithm describe here: http://blogs.sas.com/iml/index.php?/archives/80-count-the-number-of-points-in-bins-efficiently.html


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -