Reputation: 23
thanks for taking time to help me out.
Basically, I would like to generate a random number from 0 to 1, 15,000 times and if the generated value is below .25, then I would like it to display 0 in that spot in the table. If it is greater than .25, I would like to keep the original value.
Any tips on what I should use in the asterik part? The code is pasted below in the format I used:
data rand_data;
call streaminit(123);
do i = 1 to 15000;
u = rand('Uniform');
***if u < .25 then do;
0
else***
output;
end;
run;
proc print data= rand_data;
run;
Upvotes: 0
Views: 44
Reputation: 51566
It sounds like you want to replace values that are less than 0.25 with 0.
if u < 0.25 then u=0;
output;
If instead you want to ignore the values that are less than 0.25 then make the OUTPUT statement conditional.
if u >= 0.25 then output;
Given your code structure this could result in less than 15,000 observations.
Upvotes: 1