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 (January 2010, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Sun, 24 Jan 2010 11:28:33 -0000
Reply-To:   zoooom <zoooom@YAHOO.CO.UK>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   zoooom <zoooom@YAHOO.CO.UK>
Organization:   virginmedia.com
Subject:   Proc SQL help needed please.
Comments:   To: sas-l@uga.edu
Content-Type:   text/plain; format=flowed; charset="iso-8859-1"; reply-type=original

I am attempting to create a new table using proc sql that takes all the records from test_table and inner join it with items table on cust_id.

What I want to end up with with is a table that contains 1 record for each cust_id, and the flag_id associated with the min(order_date) returned after the order_date of 10/08/09.

I have tried various iterations of code and not been able to solve this problem - a slow death by syntax followed.

In the end I solved it using the below code, but is there a more efficient way to do this in one proc sql block using a subquery?

All replies greatly appreciated.

proc sql; create table table_a as select a.*, b.order_date, b.flag_id from test_table a, items b where a.cust_id = b.cust_id and b.order_date>= '10aug2009'd order by cust_id, order_date ;

data table_a; set table_a;

by cust_id; if first.cust_id; run;


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