Hi, I'm trying to merge two datasets by the same variable AcctNums:
data NewAcctNum;
set NewAcctNum;
merge Location_Data Purchases;
by AcctNums;
run;
And it gives me "Variable AcctNum has been defined as both character and numeric.". I have already changed the variable AcctNum to a Numeric variable so I have no idea what I have done wrong. Can someone help please? Thank you. (It was a 1-1 merging.)
You cannot use the set statement in merge , try the below code
data NewAcctNum;
merge Location_Data Purchases;
by AcctNums;
run;
Hi Jag. Thank you again. I tried it however it is giving me the same thing.
112 /*Merge the two datasets*/
113 data NewAcctNum;
114 merge Location_Data Purchases;
ERROR: Variable AcctNum has been defined as both character and numeric.
115 by AcctNums;
116 run;
I'm wondering if there is a way to specify whether it's character or numeric.
@aabbccwyt wrote:
Hi Jag. Thank you again. I tried it however it is giving me the same thing.
112 /*Merge the two datasets*/ 113 data NewAcctNum; 114 merge Location_Data Purchases; ERROR: Variable AcctNum has been defined as both character and numeric. 115 by AcctNums; 116 run;
I'm wondering if there is a way to specify whether it's character or numeric.
Such issues almost always arise when proc import is used for reading data. Using a data step is recommended to prevent such situations. So, if you can: fix the import. If you can't do that, you will have to process one of the datasets and convert the numeric version to char.
Does the error say “Acctnum...” or “Acctnums...”? Your merge step says Acctnums but the error you detail lists Acctnum.
be sure that you’re merging on the correct variable.
-unison
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.