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-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!

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