SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Why am I still getting this error about different lengths when I have already set the lengths?

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 88
Accepted Solution

Why am I still getting this error about different lengths when I have already set the lengths?

Hi Everyone, 

 

I am merging two databases with the same variables. However I am getting this error:

 

Multiple lengths were specified for the variable Last_Name by input data set(s). This
can cause truncation of dat

 

I have changed the lengths for all variables that were giving me this error in BOTH data sets that I'm trying to merge by using this code:

 

data handwristanzio;
set handwristanzio(rename=(Description=LASTNAMENUM));
Description = put(LASTNAMENUM, 20.);
drop LASTNAMENUM;
run;

 

However, even though the lengths are now all the same for all these variables, when I try to merge I am getting the same error!

 

I did a proc contents and double checked that all the lengths were set at 20 for each variable. 

 

What am I doing wrong?

 

Also, as a side note what are "format" and "informat" when I do proc contents? I notice that these columns are now blank for the variables I tried changing the lengths. Could that be the problem?

 

thanks in advanced!


Accepted Solutions
Solution
‎06-28-2016 10:01 AM
Frequent Contributor
Posts: 88

Re: Why am I still getting this error about different lengths when I have already set the lengths?

I ended up just dropping a number of variables because I didn't actually need all of the ones that were causing me the trouble.

 

thanks for trying Reeza and Astounding. I suppose it will remain a mystery!

View solution in original post


All Replies
Super User
Posts: 17,963

Re: Why am I still getting this error about different lengths when I have already set the lengths?

Can you post the proc contents and code that generates warning?

Frequent Contributor
Posts: 88

Re: Why am I still getting this error about different lengths when I have already set the lengths?

This is the code that generates the warning:

 

data allmergefinalanzio;
/* length Last_Name First_Name Description Site Program City $550;*/-->I commented this out when I ran the code, but I initially also tried this and it also did not work
set faanzio.handwristanzio faanzio.footankleanzio;
run;

 

This is the proc contents:

proc contents.png

Notice that all the ones with length=20 are the ones that were giving me an error

 

 

 

Super User
Posts: 5,099

Re: Why am I still getting this error about different lengths when I have already set the lengths?

You have a problem with the length of LAST_NAME.  Yet you changed a variable named DESCRIPTION.  That wouldn't solve the problem.

 

You could add before the SET statement:

 

data handwristanzio;

length last_name $ 25;
set handwristanzio(rename=(Description=LASTNAMENUM));
Description = put(LASTNAMENUM, 20.);
drop LASTNAMENUM;
run;

 

Just pick the longest length you will need.

Frequent Contributor
Posts: 88

Re: Why am I still getting this error about different lengths when I have already set the lengths?

Actually no I was just being lazy b/c I had to change a bunch of variables.

 

From my understanding the LASTNAMENUM is just a holder for the variable to change the length and then it is renamed back to Description and the LASTNAMENUM is then eventually dropped.

 

I just didn't bother changing the LASTNAMENUM for each variable because I was lazy. If I understand correctly it doesn't matter what I call this because it is just a holding variable for the change and then is eventually droppped...right?

 

Super User
Posts: 5,099

Re: Why am I still getting this error about different lengths when I have already set the lengths?

All of that sounds right.

 

Have you checked the lengths in all data sets?  The LENGTH statement should do the trick.

Frequent Contributor
Posts: 88

Re: Why am I still getting this error about different lengths when I have already set the lengths?

Hey Astounding, 

 

Ya, I checked the lengths for all variablesSmiley Sad If you scroll up a bit I pasted my proc contents and you can see Last_Name as well as a number of other variables have a length of 20. So I'm not sure why I am still getting that error message.

 

the only othet thing that it could be is the format and the informat? these are blank for these variables for some reason. I'm not entirely sure what these are or mean. Can you explain to me a bit what format and informat is? I googled but I don't think I understand. Do these need to be filled in or is ok that they are blank for these variables?

Super User
Posts: 5,099

Re: Why am I still getting this error about different lengths when I have already set the lengths?

So far so good, but that's only half of the story.

 

Since you are merging from (at least) two sources, what does the PROC CONTENTS look like for the other source(s)?  Anything different than a length of 20 there?

Frequent Contributor
Posts: 88

Re: Why am I still getting this error about different lengths when I have already set the lengths?

[ Edited ]

This is the proc contents from data set 1:

 

 

Proc contents from data set 2:

 

 

notice that for the variabels that are giving me the error they are all the same length (i.e., last name, first name site, description...)

 

do you know what's going on at all?

Super User
Posts: 5,099

Re: Why am I still getting this error about different lengths when I have already set the lengths?

There are a couple of variables that have different lengths:  CITY, PROGRAM.

 

If you to re-run your program against these data sets, I would expect to see messages about those two variables.  But I would be shocked to see messages about any of the other variables ... assuming your are careful to refer to the revised data sets in your program.

Frequent Contributor
Posts: 88

Re: Why am I still getting this error about different lengths when I have already set the lengths?

but CITY and PROGRAM are not giving me the error...these variables seem to be fine. it's only the ones above that I mentioned. that's why I don't understand what the problem is. 

Super User
Posts: 5,099

Re: Why am I still getting this error about different lengths when I have already set the lengths?

I agree with you ... it's not possible. 

 

Where to turn?  Double-check the program to make sure that it is actually referring to the revised data sets rather than the original data sets.  Other than that, there's nothing that I can imagine.

Frequent Contributor
Posts: 88

Re: Why am I still getting this error about different lengths when I have already set the lengths?

Thanks for trying astounding.

 

does anyone else have any ideas what's going on?

Super User
Posts: 17,963

Re: Why am I still getting this error about different lengths when I have already set the lengths?

My debugging process:

 

1. Confirm dataset names in procedure are correct

2. Run same code(data step or proc) BUT drop the variables that are supposed to be causing the issues first. 

 

Data want;

set data1 (drop=var1 var2)

      Data2 (drop=var1 var2);

 

run;

 

3. Show your actual code and log please. Are you creating a new table, using proc append? Proc SQL? Proc datasets?

 

Solution
‎06-28-2016 10:01 AM
Frequent Contributor
Posts: 88

Re: Why am I still getting this error about different lengths when I have already set the lengths?

I ended up just dropping a number of variables because I didn't actually need all of the ones that were causing me the trouble.

 

thanks for trying Reeza and Astounding. I suppose it will remain a mystery!

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 14 replies
  • 582 views
  • 3 likes
  • 3 in conversation