Data s1 ;
Input id age ;
Cards;
101 22
102 34
103 22
104 34
105 44
106 23
;
Data s2 ;
Input id sex $ ;
cards ;
101 M
102 F
103 M
105 M
106 F
107 M
;
Data s3 ;
Input id country $15. ;
cards ;
101 INDIA
102 USA
103 ENGLAND
104 INDIA
107 FRANCE
108 USA
;
proc sql ;
create table ex1 as
select * from s1,s2,s3 where s1.id=s2.id=s3.id;
quit;
if i run above program it gives matching data with warnings so how to avoid that warning
Hi,
SAS advise the following:
http://support.sas.com/kb/9/963.html
There are also a number of other suggestions contained in:
https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Warning-Variable-already-exists/td-p/70119
https://communities.sas.com/t5/SAS-Procedures/proc-sql-join-with-same-variable-names/td-p/48781
Regards,
Amir.
In a select clause you put the variables you want to keep on the output dataset. Using * is the equivalent of saying take everything from all contributing datasets, which means id from each datasets - which is why you get the warning. Avoid using * and code to select the data you actually want:
proc sql ; create table ex1 as select s1.id, s1.age, s2.sex, s3.country from s1, s2, s3 where s1.id=s2.id=s3.id; quit;
I think we have referred to posting logs of results often enough that you should have posted to actual log with the warning instead of making us guess which warning you might be referring to.
And the warning involving the variable coming from both sets should tell you pretty clearly not to include variable(s) from both sets if you do not want the warning to appear.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.