How to use rename in sas while merging datasets

sas

#1

Respected sir,
I want to merge dataset merge_cust_order with dataset orderlines as you can see in the following attachment

Question…The problem i am facing is that i have three common variables in two datasets with different data types which can be seen below

Thus i used the rename statement but getting following log error kindly help me…


regards
Pragya


#2

hello @sanchi_singh1,

you need to do:

data orderlines;
set orderlines;
order_date = put(order_date,datetime19.);
run;

And then do the merge.
Hope this helps!!


#3

Hi …
U can try following :

data temp(drop=Order_Date Added_By Added1);
set lib.orderlines(rename=(added=added1));
order_date=input(Order_Date,datetime19.);
Added_by=put(Added_By,$20.) ;/* u can instead on $20 give length of the variable in Merge_cust_order dataset*/
Added=input(Added1,datetime19.);
run;
/*post this sort and merge temp with Merge_cust_order dataset */
Let me know in case of any issues :slight_smile:

Regards
Meenakshi Tripathi


#4

Mam I wrote following code but after running temp dataset it gave following error as seen in the attachment



#5

HI Sanchi,

There is one syntax error in your code(I might have missed too) i.e. semicolon post set statement ;
also make sure that the format that u shared are the original formats.
for character variable to be converted in numeric format we use INPUT and for numeric to char we can use PUT
I hope this will work :slight_smile: and if not u can ask again …


#6

Is this from JIgsaw academy.I am also learning SAS from there ? Could you help me ?