BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Gil_
Quartz | Level 8
I have 2 tables i need to know based on table A date when it was last done in table b.
Table A
Id. Date
A1. 05/01/2018
A3. 05/08/2018
Table B
Id. Date
A1. 04/28/2018
A3. 04/21/2018
A1. 03/07/2018
A3. 04/16/2018

Whst i need output frrom table a and the last date from when service was done from table b

Id. Date. Date.
A1. 05/01/2018. 04/28/2018
A3. 05/08/2018. 04/21/2018
1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

What does this have to do with BI?  Also, please post test data in the form of a datastep, as such this code is untested:

proc sql;
  create table want as 
  select a.id,
            a.date,
            b.date as last_date
  from   tablea a
  left join (select id,
                    max(date) as date 
             from   tableb 
             group by id) b
  on       a.id=b.id;
quit;

View solution in original post

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

What does this have to do with BI?  Also, please post test data in the form of a datastep, as such this code is untested:

proc sql;
  create table want as 
  select a.id,
            a.date,
            b.date as last_date
  from   tablea a
  left join (select id,
                    max(date) as date 
             from   tableb 
             group by id) b
  on       a.id=b.id;
quit;
Gil_
Quartz | Level 8
Thanks will test it. What do you mean by your question? BI.
RW9
Diamond | Level 26 RW9
Diamond | Level 26

You posted the question in the BI forum, but I didn't see anything relating to BI specifically.  If so I can move to the general SAS questions area.

Gil_
Quartz | Level 8
Really sorry i didnt realize.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Discussion stats
  • 4 replies
  • 1079 views
  • 0 likes
  • 2 in conversation