SAS 9.4 (62 bit) - ERROR: Variable has been defined as both character and numeric.

Reply
New Contributor
Posts: 2

SAS 9.4 (62 bit) - ERROR: Variable has been defined as both character and numeric.

Hey All, 

I an new at SAS and also in this forum, but i hope someone can help me.

 i need to merge to different file by variable TikID 

 

here is the code: 

PROC IMPORT OUT= WORK.nesibot_2 DATAFILE= "C:\sasdata\2017\nesibot_2.xlsx"
DBMS=xlsx
rePLACE;
GETNAMES=YES;
RUN;
data TIK_2010_2016;
merge TIK_2010_2016 nesibot_2;
by TikId shana;
run;

and here is the log: 

data TIK_2010_2016;
361 merge TIK_2010_2016 nesibot_2;
ERROR: Variable TikId has been defined as both character and numeric.
362 by TikId shana;
363 run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.TIK_2010_2016 may be incomplete. When this step was stopped there
were 0 observations and 17 variables.
WARNING: Data set WORK.TIK_2010_2016 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.03 seconds

 

New Contributor
Posts: 2

Re: SAS 9.4 (62 bit) - ERROR: Variable has been defined as both character and numeric.

hey, i need to merge by TikID and shana
Super User
Posts: 7,405

Re: SAS 9.4 (62 bit) - ERROR: Variable has been defined as both character and numeric.

It means that the variable Tikld has been defined as numeric in one dataset and character in the other.

Depending on its contents, you should convert it to the correct type in the one dataset where it is defined wrongly before merging.

Most probably the mistake occurs in proc import, which is a guessing procedure.

Since you have no control over the import of Excel files, I suggest you save to csv from Excel and import from there with a data step that sets the correct variable attributes.

Using Excel as a transfer file format is, err, sub-optimal, to be polite. Excel and its brethren don't work with tables like databases (and SAS) do, but with sheets of cells that have no structure. proc import tries to do its best to create that structure, but often fails.

A properly written data step forces the structure.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 2 replies
  • 101 views
  • 0 likes
  • 2 in conversation