Hi,
Hi,
What the diffrence between this two merging ways, both of them give me diffrent num of rows(2561984 and 2561938 ),
data wyn22;
merge skzr1(in=zb1) krel;
by id_klienta;
id_cst=coalesce(id_klienta_rel, id_klienta);
if zb1=1 then output;
run;
Thanks.
proc sql;
create table wyn22_1 as
select skzr1.*, krel.*, coalesce(id_klienta_rel, skzr1.id_klienta) as id_cst from
skzr1 left join krel
on skzr1.id_klienta=krel.id_klienta;
quit;
When you have three matches in one dataset and two in the other (for a given condition), the data step merge will result in three observations (the values fronm the second observation in the second dataset will show up in the second and third match), while SQL will result in six observations (all combinations). The SQL result is called a cartesian join.
With a data step, you will also get a NOTE in the log notfiying you that more than one dataset contains multiple matches, as that is often not intended.
When you have three matches in one dataset and two in the other (for a given condition), the data step merge will result in three observations (the values fronm the second observation in the second dataset will show up in the second and third match), while SQL will result in six observations (all combinations). The SQL result is called a cartesian join.
With a data step, you will also get a NOTE in the log notfiying you that more than one dataset contains multiple matches, as that is often not intended.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.