Help using Base SAS procedures

Reg:Variable names

Reply
N/A
Posts: 0

Reg:Variable names

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
N/A
Posts: 0

Re: Reg:Variable names

Posted in reply to deleted_user
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
N/A
Posts: 0

Re: Reg:Variable names

Posted in reply to deleted_user
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;
Super Contributor
Super Contributor
Posts: 3,174

Re: Reg:Variable names

Posted in reply to deleted_user
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.
N/A
Posts: 0

Re: Reg:Variable names

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.
Ask a Question
Discussion stats
  • 4 replies
  • 134 views
  • 0 likes
  • 2 in conversation