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 (February 2006, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 14 Feb 2006 15:44:21 -0500
Reply-To:   "data _null_;" <datanull@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "data _null_;" <datanull@GMAIL.COM>
Subject:   Re: SAS DATA STEP
Comments:   To: Pavlo Row <pavlo@inorbit.com>
In-Reply-To:   <200602142006.k1EK6Qe05043@cal1-1.us4.outblaze.com>
Content-Type:   text/plain; charset=ISO-8859-1

1) to the the natural ordering you ask for you will need to read period as a "SAS date variable" using MONYY informat. If your data are in SAS data set use: periodDT=input(period,monyy.); or similar. The thing to know is SAS dates are numbers and input function reads character data. Check the docs.

2) creating the flag is easy using first. and a counter.

data work.bank; input period :monyy5. ID RESPONSE @@; format period monyy.; cards; JAN05 1234 0 APR05 1234 0 JUN05 5678 0 OCT05 5678 0 SEP05 5678 1 APR05 3456 1 JAN05 3456 0 OCT05 3456 0 SEP05 3456 1 ;;;; run; proc sort data=work.bank; by id period; run; data work.bank; set work.bank; by id period; if first.id then e = 0; e + response; event = (response eq 1)*e; drop e; run; proc print; run;

On 2/14/06, Pavlo Row <pavlo@inorbit.com> wrote: > Hello, > I have bank-related campaigns we executed in year 2005: > JAN05, APR05, JUN05, SEP05, and OCT05. A person may (RESPONSE=0) or may not respond (RESPONSE=1). A person may also have been campaigned to multiple times in different months. For example: > > PERIOD ID RESPONSE > JAN05 1234 0 > APRO05 1234 0 > > JUN05 5678 0 > OCT05 5678 0 > SEP05 5678 1 > > APR05 3456 1 > JAN05 3456 0 > OCT05 3456 0 > SEP05 3456 1 > > > There are many other possibilities here, of course.I can't even count how many (a good combinatorial problem?) > > (1) Can we sort PERIOD field so months come naturally like JAN05, APR05, JUN05, SEP05, and OCT05. If we can accomplish this (and, this isn't really necessary, but it would make tracking easier in a dataset of 3 million records or so), then > > (2) Can we flag the RESPONSE = 1 observation. If we have multiple observations where RESPONSE =1 can we flag them like the first event (RESPOSNE = 1) as EVENT1, EVENT2, EVENT3, etc. In the above example, for example, I would have something like (after sorting PERIOD, if it can be done): > > PERIOD ID RESPONSE FLAG > JAN05 1234 0 nonevent > APRO05 1234 0 nonevent > > JUN05 5678 0 nonevent > SEP05 5678 1 EVENT1 > OCT05 5678 0 nonevent > > > JAN05 3456 0 nonevent > APR05 3456 1 EVENT1 > SEP05 3456 1 EVENT2 > OCT05 3456 0 nonevent > > Thanks. > > pavlo > > > > > > > > -- > ___________________________________________________ > Play 100s of games for FREE! http://games.mail.com/ >


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