I have a source table/dataset and I want two separate target tables/datasets Target Table 1, Target Table 2 as below . Please advice.
Source table |
Target Table 1 |
Target Table 2 |
||||||||||||||||||||||||||||||||||||||||||
|
|
|
ID is the key column; Name and Phone No are non-key columns
I have tried below code and it worked too.
data source;
input id name $ ph $;
datalines;
10 AAA 123
20 BBB 234
30 CCC 434
40 DDD 343
50 EEE 442
;
run;
data Target1 ;
set one(drop = ph);
run;
data Target2;
set one(drop = name);
run;
Please suggest any other approach and also can we do it in single data step?
All suggestions are welcome.
Thank you.
Try
data table1(keep= id name) table2(keep= id ph);
set source;
run;
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.