Hello
I am getting a warning Multiple lengths were specified for the variable productId
I am adding length statement but it still exists.
Any idea for solution please?
proc sort data=t1;by appIdentity IP ;Run;
proc sort data=t2;by appIdentity IP ;Run;
Data t3;
length productId $30.;
SET t1 t2;
by appIdentity IP ;
RUN;
/*WARNING: Multiple lengths were specified for the variable productId by input data set(s). This can cause truncation of data.*/
your defined length is too short. remove the dot in your length specification btw., you're defining a length, not a format.
- Cheers -
Ask yourself why you have different lengths in the first place.
Where is the variable created?
what is the length of productID in both of those datasets? make the length as long as the longer length in the 2 datasets and the warning should go away.
To get this result, the length must be longer in T2 than it is in T1. A quick and easy fix would be to switch the order of the data sets in the SET statement:
proc sort data=t1;by appIdentity IP ;Run;
proc sort data=t2;by appIdentity IP ;Run;
Data t3;
SET t2 t1;
by appIdentity IP ;
run;
However, if this problem exists for other variables as well, this might not fix the entire problem.
Here is a short working example of @Astounding and the change of order that involves two sets everyone can see.
The Length statement alone does not change the warning.
data one; x='a'; run; data two; x='bbbbbbbbbbbbbbbbbbbbbbbbbbb'; run; data example1; length x $ 5; set one two; run; data example2; length x $ 25; set one two; run; data example3; set two one ; run;
Fix the lengths before combining the data sets if you have many variables with different lengths and do not want to see that warning.
Hello @Ronein
Suggest that you do a proc content of t1 and t2 and verify the variable lengths.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.