Date: Fri, 11 Sep 2009 12:00:27 +0530
Reply-To: Ashok R <r.ashokiyer@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ashok R <r.ashokiyer@GMAIL.COM>
Subject: Re: Help Required on Cicrcular trading
In-Reply-To: <200909101859.n8AHLSR4019023@malibu.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1
Hi Art
Thanks a lot. This is what I was exactly looking at. Thanks once again.
Ashok
On Fri, Sep 11, 2009 at 12:29 AM, Arthur Tabachneck <art297@netscape.net>wrote:
> Ashok,
>
> If the last code I proposed is actually sufficient to meet your needs then
> the relative row numbers (i.e., relative within each symbol) are readily
> available during the processing loop. E.g.,
>
> data have;
> infile datalines;
> input symbol seller_code $ buyer_code $ price quantity datetime ;
> informat datetime anydtdtm17.;
> date=datepart(datetime);
> time=timepart(datetime);
> format date ddmmyy8.;
> format time time8.;
> datalines;
> 100 a b 100 100 15OCT2008:15:30:00
> 100 d e 150 90 15OCT2008:10:45:50
> 100 b c 200 100 15OCT2008:15:30:00
> 100 e f 220 100 15OCT2008:15:30:00
> 100 f g 180 100 15OCT2008:15:30:00
> 100 c b 160 100 15OCT2008:15:30:00
> 100 l m 300 100 15OCT2008:15:30:00
> 100 p q 350 100 15OCT2008:15:30:00
> 100 m n 400 90 15OCT2008:15:30:00
> 100 n o 450 90 15OCT2008:15:30:00
> 100 o l 500 90 15OCT2008:15:30:00
> ;
> proc sort data=have;
> by symbol;
> run;
> proc transpose data=have out=transposed;
> var seller_code buyer_code price quantity date time datetime;
> by symbol;
> run;
> data want (keep=symbol Normal_Path price quantity date
> time datetime Group_Circular_Path Track);
> set transposed;
> array indata(*) $ col:;
> array keepdata(7,32000) $20;
> array Sequence(32000);
> retain keepdata;
> format Group_Circular_Path Track $200.;
> if mod(_n_,7) then do i=1 to dim(indata);
> keepdata(mod(_n_,7),i)=indata(i);
> end;
> else do;
> do i=1 to dim(indata);
> keepdata(7,i)=indata(i);
> end;
> do i=1 to dim(indata);
> Group_Circular_Path=catx('-',keepdata(1,i),keepdata(2,i));
> Track=i;
> Counter=1;
> Sequence(Counter)=i;
> last_link=keepdata(2,i);
> do j=i to dim(indata);
> if keepdata(1,j) eq last_link then do;
> Group_Circular_Path=catx('-',Group_Circular_Path,
> keepdata(2,j));
> Counter+1;
> Track=catx('-',Track,j);
> Sequence(Counter)=j;
> last_link=keepdata(2,j);
>
> *Found group circular path;
> if keepdata(1,i) eq keepdata(2,j) then do;
> do k=1 to Counter;
> Normal_Path=catx('-',keepdata(1,Sequence(k)),
> keepdata(2,Sequence(k)));
> price=keepdata(3,Sequence(k));
> quantity=keepdata(4,Sequence(k));
> date=keepdata(5,Sequence(k));
> time=keepdata(6,Sequence(k));
> datetime=keepdata(7,Sequence(k));
> output;
> end;
> leave;
> end;
> end;
> end;
> end;
> end;
> run;
>
> Art
> -------
> On Thu, 10 Sep 2009 22:55:45 +0530, Ashok R <r.ashokiyer@GMAIL.COM>
> wrote:
>
> >Hi Art
> >
> >Need help to include the track of row numbers in your previous output.
> >Please help
> >--
> >Ashok
>
--
Ashok
|