BookmarkSubscribeRSS Feed
SefiB
Calcite | Level 5

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

 

2 REPLIES 2
SefiB
Calcite | Level 5
hey, i need to merge by TikID and shana
Kurt_Bremser
Super User

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.

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 450 views
  • 0 likes
  • 2 in conversation