BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
vraj1
Quartz | Level 8

I have a dataset and want to merge with another dataset but i have different lengths for variables in both the datasets.

In this case i am using length statement to match the lenghts but i get warnings.

data ae010;
 length AESPID $10 AESTDTC AEENDTC $20 AESEV $50 AECONTRT aeser $1;
 set ae010;
run;

WARNING: Multiple lengths were specified for the variable AESPID by input data set(s). This can
cause truncation of data.
WARNING: Multiple lengths were specified for the variable AESEV by input data set(s). This can
cause truncation of data.
WARNING: Multiple lengths were specified for the variable AESER by input data set(s). This can
cause truncation of data.
WARNING: Multiple lengths were specified for the variable AECONTRT by input data set(s). This
can cause truncation of data.
WARNING: Multiple lengths were specified for the variable AESTDTC by input data set(s). This
can cause truncation of data.
WARNING: Multiple lengths were specified for the variable AEENDTC by input data set(s). This

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

This is perfectly normal behaviour. SAS warns you that data may be lost due to truncation.

You might try to use

options VARLENCHK = NOWARN;

before you run the data step.

Take care to reset the option immediately after the step, as these warnings are there for a purpose.

View solution in original post

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

I can't really tell from what you posted there, perhaps some sample test data of both datasets - in the form of a datastep would help explain.  Some thoughts, you can alter length of variables using the proc datasets statement - probably easiest.  You can also SQL join the two datasets as that should take the longest length:

proc sql;
  create table WANT as
  select  coalesce(A.ID,B.ID) as ID length=200
  from    HAVEA A
  full join  HAVEB B
  on       A.ID=B.ID;
quit;
vraj1
Quartz | Level 8

in the output i get the length which i changed but i am still getting the warning message.

Kurt_Bremser
Super User

This is perfectly normal behaviour. SAS warns you that data may be lost due to truncation.

You might try to use

options VARLENCHK = NOWARN;

before you run the data step.

Take care to reset the option immediately after the step, as these warnings are there for a purpose.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, its up to you what you mark the answer, I would however point out here that all you are doing is hiding the problem and that it might come back to haunt you later on, say when you document ends up on someones desk and half the data has been truncated out.   Its never a good idea to hide problems.

Kurt_Bremser
Super User

I can only second @RW9's advice. Make your data clean, have strict structures defined, and you won't have such problems. And if you have them, you know that something is wrong with your input data.

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
  • 5 replies
  • 2411 views
  • 2 likes
  • 3 in conversation