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
;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: