LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (July 2006, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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, antje.schuele@googlemail.com <antje.schuele@GOOGLEMAIL.COM> wrote:

>Dear Newsgroup, > >I'd like you to ask for help for a problem I have been sitting since >yesterday. > >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 - >something > >The "something" is what I want to select. For person2 it is >"something1", not "something2", because I always need the first >not-event. >So I started to write my program like that: > >data test; > length sth $256; > set dataset; > array some col1-col30; > do cc = 1 to 30; > select; > when (some(cc) eq "event" AND sth = . ) sth = some(cc); > when (some(cc) eq " " AND sth = . ) sth = some(cc); > otherwise sth = some(cc); > end; > end; > drop cc; >run; > >Has anyone an idea how to filter out the "something"? > >Thanks a lot in advance. > >Antje

Hi, it could be a simple array solution. You can identify "event" (here just E), so picking the first non-E is:

data out (drop=i); input ID $ (var1-var10) ($); length sth $10; array choose [10] var1-var10; do i=1 to dim(choose); if choose(i) ne 'E' then do; sth = vname(choose(i)) || ' = ' || choose(i) ; leave; end; end; cards; 1 E E E S1 E E E E E S2 2 E E E E E E S2 E E E ; proc print; run;

Is that the only reason you are transposing? Don't forget " sort - set by - first.var/last.var ".

A


Back to: Top of message | Previous page | Main SAS-L page