Date: Sun, 17 Jul 2005 08:12:38 -0700
Reply-To: Jairaj Sathyanarayana <jairajs@gmail.com>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Jairaj Sathyanarayana <jairajs@GMAIL.COM>
Subject: Re: Merging datasets : Help
In-Reply-To: <ff8cee740507162348788ab418@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
KK-
Your code for merging does not have a BY statement. This is the reason
your 84th obs has the problem it has.
I am assuming you just forgot to put a BY statement in, because you do
mention that you want to merge them by date & timestamp.
Also, reconsider your 'if a & b then output;' line. This means that
only matching obs from both datasets will be output. But from your
post it seems like you want 'trades' to be the controlling dataset.
As a FYI... be careful when using timestamps as merge keys.
Hope this helps.
Jairaj
On 7/16/05, Kiran Kumar <kk.chikky@gmail.com> wrote:
> Dear Sas users:
>
> I am getting struck in using MERGE statement.
> I am trying to get a "consolidate" dataset by merging two datasets
> namely, trades and test datasets. "consolidate" dataset should
> contain each and every row of trades dataset and append appropriate
> prebestbuy...postbestsell columns by date and timestamp.
>
> Using the following code;
>
> data consolidate;
> merge trades(in=a) test(in=b);
> if a and b then output;
> keep date timestamp price Quantity PreBestBuy PreBestSell PostBestBuy
> postBestSell;
> run;
>
> Input and output datasets are attached.
> For eg: on 15Nov2001, Timestamp 11:44:45 (84th observation) appears 4
> times in trades data and 8 times in test data. I would like to have
> consolidate data also only 4 times. Where as the above code writes 8
> times.
>
> Appreciate your kind help.
>
> Thank you in advance,
>
> Best Regards,
> kk
>
|