Date: Tue, 25 Jul 2006 06:37:12 -0400
Reply-To: Arild S <sko@KLP.NO>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Arild S <sko@KLP.NO>
Subject: Re: Select field of data set transposed
On Tue, 25 Jul 2006 02:20:59 -0700, firstname.lastname@example.org
>I'd like you to ask for help for a problem I have been sitting since
>The dataset I use is transposed so every row is the sequence of events
>of one person. Sometimes one row contains five events, others just 2 or
>others even 30.
>My aim is to select the FIRST event of every user that is different
>from these I have in a separate list.
>For example (columns are seperated here via "-"):
>person1: event - event - something - event
>person2: event - something1 - event - event - event -event - something2
>- event - event
>person3: event - event - event - event - event - event - event -
>The "something" is what I want to select. For person2 it is
>"something1", not "something2", because I always need the first
>So I started to write my program like that:
> length sth $256;
> set dataset;
> array some col1-col30;
> do cc = 1 to 30;
> when (some(cc) eq "event" AND sth = . ) sth = some(cc);
> when (some(cc) eq " " AND sth = . ) sth = some(cc);
sth = some(cc);
> drop cc;
>Has anyone an idea how to filter out the "something"?
>Thanks a lot in advance.
Hi, it could be a simple array solution.
You can identify "event" (here just E), so picking the first
data out (drop=i);
input ID $ (var1-var10) ($);
length sth $10;
array choose  var1-var10;
do i=1 to dim(choose);
if choose(i) ne 'E' then do;
sth = vname(choose(i)) || ' = ' || choose(i) ;
1 E E E S1 E E E E E S2
2 E E E E E E S2 E E E
Is that the only reason you are transposing?
Don't forget " sort - set by - first.var/last.var ".