@NP2212 wrote:
I want to add columns not rows. Values for another columns from other datasets. Variable type remains same but all variables from different datasets. All datasets are in different library. Can You suggest for above conditions? and for changing certain number of tables how much time taken? (approximately 50 tables)
Which now brings up the question of which row to do you want which column value assigned to.
If you have variable, or combination of variables, that can be used to match values then this may be next to trivial or a nightmare depending on whether your identification variables have duplicates in one or more of the "other datasets".
If there are no duplicates of the combination of identification variables then either a Data step Merge or SQL Join could be used. But duplicates can mean more work.
A simple MERGE EXAMPLE: Note that data step merge requires that the sets be sorted by the Id variable(s) by default.
data one;
input id a b;
datalines;
1 1 11
2 2 22
3 3 33
;
data two;
input id c;
datalines;
1 111
2 222
3 333
;
data three;
input id d;
datalines;
1 1111
3 3333
;
data want;
merge one two three;
by id;
run;
To see what duplicates can cause problems with this approach make 2 or more, differing number, of rows with different values of a, b, c or d but the same Id in 2 of the sets. Note: I intentionally did not provide an Id=2 in the last set to show what happens:
Sql
proc sql;
create table want as
select t1.id, t1.a, t1.b, t2.c, t3.d
from one as t1
left join
two as t2
on t1.id=t2.id
left join
three as t3
on t1.id=t3.id
;
quit;
Also modify the sets to have duplicates of the ID to see what happens.
I used LEFT join which is just one way of combining these. You really should provide example data, starting and desired result because there are many ways to combine them and you likely don't want all of them.
... View more