BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Beto16
Obsidian | Level 7

.   Hi I have 2  tables  one  has 7k.   Records table 2 has 14k

 

i want  to bring every thing from table one 7k records and only the data from table 2 matches...enclose is my  code

 

proc sql;

create table temp2 as

select one.*, two.atm as b_atm, two.date as b_date

from one,two

where one.id=two.id and two.date gt  one.date

group by one.id

having two.date-one.date =min(two.date-one.date);

 

create table want2 as 

select temp2.*,two.id as c_id ,two.date as c_date 

From temp2,two 

 

where  temp2.id =two.id and two.date  gt temp2.date

group by temp2.id

having two.date- temp2.date=min(two.date-temp2.date);

quit;

 

thanks for assistance 

1 ACCEPTED SOLUTION

Accepted Solutions
mbuchecker
Quartz | Level 8
Hi Beto16,
Your title says "left join is not working" but I do not see a left join in your code. It is all inner join. Can you be more specific as to what you are getting and what you want to get?
Michelle

View solution in original post

2 REPLIES 2
mbuchecker
Quartz | Level 8
Hi Beto16,
Your title says "left join is not working" but I do not see a left join in your code. It is all inner join. Can you be more specific as to what you are getting and what you want to get?
Michelle
Beto16
Obsidian | Level 7
Sorry YOUR Right ..I Must Have Pasted Wrong Code

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1976 views
  • 1 like
  • 2 in conversation