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!
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!
Can you post the proc contents and code that generates warning?
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:
Notice that all the ones with length=20 are the ones that were giving me an error
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.
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?
All of that sounds right.
Have you checked the lengths in all data sets? The LENGTH statement should do the trick.
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?
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?
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?
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.
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.
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.
Thanks for trying astounding.
does anyone else have any ideas what's going on?
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?
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!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.