BookmarkSubscribeRSS Feed
Ronein
Meteorite | Level 14

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.*/
6 REPLIES 6
Oligolas
Barite | Level 11

your defined length is too short. remove the dot in your length specification btw., you're defining a length, not a format.

________________________

- Cheers -

tarheel13
Rhodochrosite | Level 12

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.

Astounding
PROC Star

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.

ballardw
Super User

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.

 

Sajid01
Meteorite | Level 14

Hello @Ronein 
Suggest that you do a proc content of t1 and t2 and verify the variable lengths.

SAS Innovate 2025: Register Now

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1108 views
  • 2 likes
  • 7 in conversation