Hi there,
I tried to merge two table where variable lengths are different in two different table for the same variable. Can anyone help me writing the code to add these two table with set statement plco.
Table1:
Student_ID Name
101 John
103 Allison
105 Michael
Table2:
Student_ID Name
107 Johan
109 Chowdhury
Thanks,
easiest is to override the length before the set.
data want;
length student_id $ 5 name $ 25; /* what ever lengths you might need*/
merge table1 table2;
by student_id;
run;
OR instead of merge:
set table1 table2;
depending on what you are attempting to do.
Thanks ballardw,
I need the set statement and it worked when I write 'set Table2 Table1', but some observation doesn't come to it's total length when I write 'set Table1 Table2',. It's because variable 'Chowdhury' is bigger then any other variables. Do you know a solution to make it work for 'set Table1 Table2'. let's say for the following table. Thanks,
Table1:
Student_ID Name Course
101 John Math
103 Allison English
105 Michael Geography
Table2:
Student_ID Name Course
107 Johan Math
109 Chowdhury English
Did you try adding the length statement before the SET statement? Did you make the length at least as long as the longest value of the variables concerned?
SQL could take care of it .
proc sql;
create table want as
select * from A
union all corr
select * from B ;
quit;
Xia Keshan
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.
Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.
Find more tutorials on the SAS Users YouTube channel.