proc sql noprint;
create table baseball as
select a.Name , a.dob , a.gender , b.name, b.start, b.end
from salaries b inner join
TMP2.players a
on a.name = b.name;
quit;
I have a dataset that have the same values but different column names. a.Name , a.dob , a.gender all have different column names. How do I change them to make them the same as the b table? I also want the common variable to be name to join them.
@pw7632 wrote:
proc sql noprint;
create table baseball as
select a.Name , a.dob , a.gender , b.name, b.start, b.endfrom salaries b inner join
TMP2.players a
on a.name = b.name;
quit;
I have a dataset that have the same values but different column names. a.Name , a.dob , a.gender all have different column names. How do I change them to make them the same as the b table? I also want the common variable to be name to join them.
A SAS dataset cannot have two variable with the same name. So in your example code the second variable named NAME is not going to be written. Just provide new name in the select statement. There is no need for two copies of NAME since your join is requiring them to be the same value. But if both dataset had DOB and GENDER for example you could select both and rename one of them.
create table baseball as
select a.Name
, a.dob
, a.gender
, b.dob as dob2
, b.gender as gender2
, b.start
, b.end
from salaries b
inner join TMP2.players a
on a.name = b.name
;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.