02-27-2017 01:47 AM
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"
merge TIK_2010_2016 nesibot_2;
by TikId shana;
and here is the log:
361 merge TIK_2010_2016 nesibot_2;
ERROR: Variable TikId has been defined as both character and numeric.
362 by TikId shana;
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
02-27-2017 02:22 AM
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.