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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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