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
Hi

I have 2 tables table a and table b
I want everything coming from table a An only where we match table b.

From table. A left join table b on a.tid =b.tid and a.date = b.date



Table a has 7500 records table b has 100k records when I run it i get 7200 records ... I don't know why it's dropping 300 records ....thanks
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

You are getting MORE records than exist in the source table A, not LESS.

This happens when there are mulitple records in B for some of the key variables. So in this case there are some values of ID and DATE that have more than one record in table B and also appear in table A.

View solution in original post

7 REPLIES 7
Tom
Super User Tom
Super User

You most have a WHERE or a GROUP BY or some other way that is subsetting the results.

Without seeing the full query and the SAS log it is hard to diagnosis further.

Patrick
Opal | Level 21

Is there anything else in your SQL that could cause this drop of records (i.e. a DISTINCT in the SELECT clause)?

 

Please post your SQL code and the related log.

Gil_
Quartz | Level 8
From table a left join table b on b.date = a.date And b.id =a.id
And b.tracking is not null
), run;

Table a has 74289 records table b has 200k records
My output is 74315 ... where do I put where statement after on replaces 1st and. ?
Tom
Super User Tom
Super User

You are getting MORE records than exist in the source table A, not LESS.

This happens when there are mulitple records in B for some of the key variables. So in this case there are some values of ID and DATE that have more than one record in table B and also appear in table A.

art297
Opal | Level 21

First you were saying that you weren't getting enough records .. now you're showing too many.

 

Like others have said, post your code and some example data, and an example data file of what you expect.

 

Art, CEO, AnalystFinder.com

 

Gil_
Quartz | Level 8
Hi Tom your right I just noticed dup with same date and I'd from table a. That's ok what a relief .... follow up in where statement and grouping where do I add where after 1st and ?
Gil_
Quartz | Level 8
I figured it out art thanks for response I had dups

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1308 views
  • 1 like
  • 4 in conversation