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 (May 2008, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 26 May 2008 13:15:08 -0400
Reply-To:     Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject:      Re: Seperating Events

I have no solution, but a way how that could be managed: but a question: the event1, event2, ... - do they contain strings all with the length 6 (=6 products). You wrote it, but to be sure... In that case you might do something like:

define a array array e(*) event1-eventxxx;

2. a loop through all events: do i=1 to dim(e);

3. in that loop: split the event-strings in 6 parts with substr

each part represents a product. So substr(e(i),1,1) -> P1, substr(e (i),2,1) -> P2, ... By the contents, assign all the variables you want (you are still at the 1st obs!) and OUTPUT after assigning all what you want.

So for the first obs you have several OUTPUTs

last.: DROP all variables you don't want to see (EVENT1-EVENTxxx, ...)

Don't know if it works, only a idea...


On Mon, 26 May 2008 10:31:16 -0400, M D <tant07@GMAIL.COM> wrote:

>Hello, > >I have an unusual dataset of the following form: > >ID Day Event1 Event2 Event3 ..... Event31 >1 1 199990 901090 990091.... > >where each event (Event1, Event2, Event2...) indicates choice for 6 >different products. >1 indicates that the product was present in the choice set and was selected, >0 indicates that the product was present in the choice set, but was not >selected, > >and 9 indicates that the product was not present in the choice set. > >I want to create a new dataset of the following form: > >ID Day Event P1 P2 Choice >1 1 1 6 1 2 >1 1 2 2 3 4 >1 1 2 4 3 4 >1 1 2 6 3 4 > 1 1 3 3 6 3 > 1 1 3 4 6 3 >and so on... > >where ID, Day is same as the original datast, Event indicates the event >column (i.e. Event1 = 1, Event23=23 and so on..) >P1 and P2 indicates the product choices where P1 indicates product >no. with 0 (product is in the choice set, but not selected) and P2 indicates >product no. with 1 (product is in the choice set and is selected). Finally, >"Choice" indicates the number of products present in the choice set. > >I am a true SAS novice, and have no idea how to create this new dataset. > >Please help me with this. > >Thank you in advance, > >Mike

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