Date: Thu, 13 Oct 2005 10:04:15 -0400
Reply-To: Wensui Liu <liuwensui@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Wensui Liu <liuwensui@GMAIL.COM>
Subject: Re: Assigning a Random Number
In-Reply-To: <1129208666.757636.326770@g49g2000cwa.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
proc sort data = one (keep = b) out = one_temp nodupkey;
by b;
run;
data two;
set one_temp;
number = rannor(1);
run;
proc sort data = two;
by b;
run;
proc sort data = one;
by b;
run;
data three;
merge one two;
by b;
run;
On 10/13/05, prasad_prabhud@hotmail.com <prasad_prabhud@hotmail.com> wrote:
>
> I have the following sample data:
>
> data one;
> input a b;
> cards;
> 1 21
> 2 28
> 3 28
> 4 50
> 5 34
> 6 34
> 7 34
> 8 12
> 9 23
> 10 23
> 11 23
> 12 23
>
> I want to assign the Random number in such way that if value of "b" is
> same for "a" then Random number should be same.
> I am looking for the following kind of Random Number starting with
> X0000000001
>
> My output should look like the following:
> 1 X0000000001
> 2 X0000000002
> 3 X0000000002
> 4 X0000000003
> 5 X0000000004
> 6 X0000000004
> 7 X0000000004
> 8 X0000000005
> 9 X0000000006
> 10 X0000000006
> 11 X0000000006
> 12 X0000000006
>
--
WenSui Liu
(http://statcompute.blogspot.com)
Senior Decision Support Analyst
Cincinnati Children Hospital Medical Center