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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.