Date: Mon, 15 Sep 2008 19:04:35 -0400
Reply-To: Ya Huang <ya.huang@AMYLIN.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ya Huang <ya.huang@AMYLIN.COM>
Subject: Re: Count number of unique values in a column vector in IML
First time play around IML. I did find a function 'unique', and
it seems to wrok fine:
proc iml;
a={0 0 0 1 1 2 2 2};
print a;
b=unique(a);
print b;
run;
a
0 0 0 1 1 2 2 2
b
0 1 2
On Mon, 15 Sep 2008 18:17:53 -0400, P. Cristian Gugiu <crisgugiu@YAHOO.COM>
wrote:
>Hi all. I have a variable that represents the group an individual belogs
>to. I would like to calculate the number of group levels by counting the
>number of unique values for a variable in IML. For example,
>
>Variable X
>0
>0
>0
>1
>1
>2
>2
>2
>
>So, variable X has 3 group levels (0, 1, 2). Anyone know how to define a
>variable that is equal to the number of unique values in X?
>
>thanks,
>Cristian
|