BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi i have 3 datasets a,b,c and the names for dataset A=cus_name and in dataset B the name is F_name and in datset C the name is l_name now i want to create a dataset D and set all the three datasets .But i wnat to keep a condition like if cus_name,F_name and l_name then the name of the variable should be made to final_name in the final dataset D.and all the three variable obs should come in to the variable as final_name .The observations are different in all three datasets.(without using rename or label)



data a;
input cus_name$;
cards;
nani
run;


data b;
input f_name$;
cards;
rani
run;


data c;
input l_name$;
cards;
raju
run;


output

final_name

nani
rani
raju
4 REPLIES 4
deleted_user
Not applicable
Hi,

Please try this..
I didn't get your requirement.
I tried with what i have understood

data d(drop=cus_name f_name l_name);
set a b c;
final=COALESCEC(cus_name,f_name,l_name);
run;

Regrds,
skm
deleted_user
Not applicable
Hi,
You can try the following:

data D;
set a(rename = (cus_name = Final_Name)
b(rename = (f_name = Final_Name)
c(rename = (l_name = Final_Name)
run;
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
The post describes a "data interleave" technique, not a "data merge" requirement? I really don't understand why you would want to create an output file having observations where any one contributing variable name will be blank -- that will be the behavior result when using SET instead of considering somehow doing a MERGE (however you would need to have some BY variable list to use with a merge process.

Honestly, the purpose of this example, as described in your post, appears somewhat curious, given that you have mentioned "set", even though you really mean to do some type of merge, right?

I'm a bit baffled how this point wasn't raised previously with the post/thread, frankly.

Scott Barry
SBBWorks, Inc.
deleted_user
Not applicable
I haven't used merge because in the example given, I couldn't find any common key. And the output which is required is 3 rows instead of 1 row.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 958 views
  • 0 likes
  • 2 in conversation