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 (March 2003, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 31 Mar 2003 11:10:47 -0500
Reply-To:     Yu Guo <Yu.Guo@VERISPAN.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Yu Guo <Yu.Guo@VERISPAN.COM>
Subject:      Re: left join last observation
Comments: To: tin-shun-jimmy chan <jimmy.chan@HEC.CA>

Tested code on SAS V8.2 --------------------------- data t1; informat date yymmdd10.; format date yymmdd10.; input type $ quantity @12 date YYMMDD10.; cards; a 30 20000801 a 45 20000806 b 50 20000921 b 52 20000922 b 16 20000930 ;;;

data t2; input type $ price; cards; a 15 b 16 ;;;

proc sort data=t1; by type date; run;

data t3; set t1; by type; if last.type = 1 then output; run;

proc sql; create table final as select * from t3 left join t2 on t3.type = t2.type ;; quit;

From: tin-shun-jimmy chan <jimmy.chan@HEC.CA> on 03/31/2003 11:40 AM Please respond to tin-shun-jimmy chan <jimmy.chan@HEC.CA>@SMTP@ExchangePA To: SAS-L@LISTSERV.UGA.EDU@SMTP@ExchangePA cc:

Subject: left join last observation

Hi all,

I want to know how can I LEFT JOIN the last observation of each year in one dataset to another dataset. The situation is kind of...

Dataset 1

Type quantity date a 30 20000801 a 45 20000806 b 50 20000921 b 52 20000922 b 16 20000930

Dataset 2

Type price a 15 b 16

The result that I want to obtain is

Type price quantity date a 15 45 20000806 b 16 16 20000930

I just remember that I need to use some kind of LAST..., so could you please tell me how to do this ? Thanks a lot.

Jim


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