Hello guys,
I know this problem has been answered a couple of times. But I tried most of the solution but I'm still unable to merge them and it's quite frustrating... so hope that you guys can help me see what's the problem here:
The data MATCH has account ID (numerical) with other variables and TOMATCH has only account ID (numerical) and counts (numberical). Hence, I would like to merge the files so that my new data COMBINEFILES will have the account numbers and the counts.
data match;
set match(rename=(account=acc));
account=input(acc,f15.);
drop acc;
run;
data tomatch;
set tomatch (rename=(account=acc));
account=input(acc,f15.);
drop acc;
run;
data combinefiles;
merge match (in=a) tomatch (in=b);
by account;
if a;
run;
But the output is always:
ERROR: Variable b has been defined as both character and numeric.
ERROR: Variable a has been defined as both character and numeric.
Really appreciate if you guys can help me.
Really sorry... I didn't check my variables properly as it's a huge dataset...
I have a variable named a and b so that's why I am unable to merge.
But thank you once again! Will check more diligently next time!
data match1;
input Account;
datalines;
1
2
3
5
;
data tomatch1;
input Account;
datalines;
1
2
3
6
;
data match;
set match1(rename=(account=acc));
account= put(acc,15.);
drop acc;
run;
data tomatch;
set tomatch1 (rename=(account=acc));
account=put(acc,15.);
drop acc;
run;
data combinefiles;
merge match1 (in=a) tomatch1 (in=b);
by account;
if a;
run;
Your error doesn't match your data description.
Please post code and log if you need further assistance.
@pearsoninst Is correct about checking your IN variables.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.