- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 01-06-2010 06:28 PM
(2888 views)
Hello,
I want to assign random numbers 1, 2, 3 to subjects in a dataset. Not sure how to use RANUNI function. Please help.
Thanks,
/Sukanya
I want to assign random numbers 1, 2, 3 to subjects in a dataset. Not sure how to use RANUNI function. Please help.
Thanks,
/Sukanya
7 REPLIES 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I'm not sure I understand your question. If you want to assign dummy treatments to a list(data set) of subjects that is easily done using the RANTBL function.
[pre]
trt = rantbl(seed,1/3,1/3);
[/pre]
This assigns one of three values 1,2,3 with equal probability for each. I use this technique to create dummy treatments when working to data that is still blinded.
If you need something more complex like generating a plan that can be done too.
[pre]
trt = rantbl(seed,1/3,1/3);
[/pre]
This assigns one of three values 1,2,3 with equal probability for each. I use this technique to create dummy treatments when working to data that is still blinded.
If you need something more complex like generating a plan that can be done too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the quick reply.
Sorry I want to assign 0, 1, 2. How do I do that. How does Seed value controls ?
Thanks,
/Sukanya
Sorry I want to assign 0, 1, 2. How do I do that. How does Seed value controls ?
Thanks,
/Sukanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
ranuni() gives you uniform distributed random numbers between 0 and 1.
The seed is the starting point from where you start picking the random numbers out of a very very long list of numbers.
If you use '0' as seed then the system time is used as seed and so the starting point is different for every execution of your code - resulting in an always different set of random numbers.
To assign random numbers between 0 and 2 use the following line in a data step:
RandomNumber=floor(ranuni()*3);
HTH
Patrick
The seed is the starting point from where you start picking the random numbers out of a very very long list of numbers.
If you use '0' as seed then the system time is used as seed and so the starting point is different for every execution of your code - resulting in an always different set of random numbers.
To assign random numbers between 0 and 2 use the following line in a data step:
RandomNumber=floor(ranuni(
HTH
Patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
> Thanks for the quick reply.
>
> Sorry I want to assign 0, 1, 2. How do I do that.
Subtract 1.
> How does Seed value controls ?
SAS has online Help. It will explain the SEED and how to use it better than I can.
>
> Thanks,
> /Sukanya
>
> Sorry I want to assign 0, 1, 2. How do I do that.
Subtract 1.
> How does Seed value controls ?
SAS has online Help. It will explain the SEED and how to use it better than I can.
>
> Thanks,
> /Sukanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks All. This really helps. Now I understand how Seed value controls.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi
Do you just want to assign random number or want to select samples from a big population.
If it is the second case use PROC SURVEYSELECT.
It is pretty straight forward.
Sandhya.
Do you just want to assign random number or want to select samples from a big population.
If it is the second case use PROC SURVEYSELECT.
It is pretty straight forward.
Sandhya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
No, I just want to assign the random number for each observation randomly.
/Sukanya
/Sukanya