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

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!

1 ACCEPTED SOLUTION

Accepted Solutions
christinagting0
Quartz | Level 8

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

14 REPLIES 14
Reeza
Super User

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

christinagting0
Quartz | Level 8

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

 

 

 

Astounding
PROC Star

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.

christinagting0
Quartz | Level 8

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?

 

Astounding
PROC Star

All of that sounds right.

 

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

christinagting0
Quartz | Level 8

Hey Astounding, 

 

Ya, I checked the lengths for all variables:( 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?

Astounding
PROC Star

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?

christinagting0
Quartz | Level 8

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?

Astounding
PROC Star

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.

christinagting0
Quartz | Level 8

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. 

Astounding
PROC Star

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.

christinagting0
Quartz | Level 8

Thanks for trying astounding.

 

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

Reeza
Super User

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?

 

christinagting0
Quartz | Level 8

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!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

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