Hello,
I have two tables :
Data t1 ;
Input texte1 ;
Cards ;
ERGO
ERGY
DERMU
FERMI
VERMO
;
Run
Data t2 ;
Input texte2 ;
Cards ;
ERGO
CRGY
DERMU
ZERMI
VERMO
;
Run
I would like to create a 3rd table with items that are only present in one.
And get :
Texte1 Texte2
ERGY CRGY
FERMI ZERMI
thank you for your help
Run a proc sort nodupkey on both datasets. As there is not link between the two its hard to say how to put them together:
proc sort data=t1 nodupkey; by texte1; run; proc sort data=t2 nodupkey; by texte2; run; data want; merge t1 t2; by ...; run;
Run a proc sort nodupkey on both datasets. As there is not link between the two its hard to say how to put them together:
proc sort data=t1 nodupkey; by texte1; run; proc sort data=t2 nodupkey; by texte2; run; data want; merge t1 t2; by ...; run;
Data t1 ;
Input texte1 $;
Cards ;
ERGO
ERGY
DERMU
FERMI
VERMO
;
Run;
Data t2 ;
Input texte2 $ ;
Cards ;
ERGO
CRGY
DERMU
ZERMI
VERMO
;
Run;
proc sql;
create table x1 as
select texte1 from t1
except
select texte2 from t2 ;
create table x2 as
select texte2 from t2
except
select texte1 from t1 ;
quit;
data want;
merge x1 x2;
run;
Hi you can try the below code , but it will give you texte1 and texte2 value with some blank (missing) observations , you have to write one more step to remove the blank and keep only the unique value
can any one suggest how to do that in a single step
proc sql;
create table want as
select texte1 , texte2 from t1 full join t2
on texte1 = texte2
where texte1 in (select texte1 from t1 left join t2 on texte1=texte2 where texte2 is null)
or texte2 in (select texte2 from t2 left join t1 on texte2=texte1 where texte1 is null);
quit;
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.
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.