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

I used the following two methods and found out there is difference in number of records for each method:

data x;

merge SASDATA.TU_LAIDC_APAC(in=a) SASDATA.TU_LAIDC_APAC_corp(in=b);

by id;

if a or b;

run;

The above results in 154718 records.

when I use the following:

proc sql;

create table xx as

select  coalesce(a.id,b.id) as id

from SASDATA.TU_LAIDC_APAC a  full outer join SASDATA.TU_LAIDC_APAC_corp b

on a.id=b.id;

quit;

This one results in 155047 records.

where could be the difference?

1 ACCEPTED SOLUTION

Accepted Solutions
Paul_Kent_SAS
SAS Employee

you probably have some id va.uess with 2 or more rows in both datasets. suppose you have id=99 twice in both datasets - SQL will form the cartesian join of these (4 output records).  datastep will advance  each by group until the end of the shorter one, and then hold that row until the end of the longer one (2 output records)

View solution in original post

1 REPLY 1
Paul_Kent_SAS
SAS Employee

you probably have some id va.uess with 2 or more rows in both datasets. suppose you have id=99 twice in both datasets - SQL will form the cartesian join of these (4 output records).  datastep will advance  each by group until the end of the shorter one, and then hold that row until the end of the longer one (2 output records)

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
  • 1 reply
  • 9235 views
  • 1 like
  • 2 in conversation