BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
bhca60
Quartz | Level 8

I'm getting this warning for diagnosis code which has varying lengths - the longest (including the decimal) is 7.

 

How do I fix it so that I stop getting this error? I tried the below:


23         data aa_dd;
24         length icd $7;
25         merge aa(in=ina)
26         	  diag;
27         by claimHeaderId;
28         if ina;
29         
30         run;

WARNING: Multiple lengths were specified for the variable icd by input data set(s). This can cause truncation of data.

      
1 ACCEPTED SOLUTION

Accepted Solutions
AMSAS
SAS Super FREQ

Compare the variable lengths in the 2 datasets aa and diag
My guess is you have a common variable on both datasets that has different lengths defined.
You might want to run a PROC CONTENTS on them both

Here's a simple example:

data test10 ;
	length a $10 ;
	a="1234567890" ;
	output ;
run ;

data test8 ;
	length a $8 ;
	a="12345678" ;
	output ;
run ;

data join ;
	set test8 test10 ;
run ;

and here's the log:

2    data test10 ;
3        length a $10 ;
4        a="1234567890" ;
5        output ;
6    run ;

NOTE: The data set WORK.TEST10 has 1 observations and 1 variables.
NOTE: At least one W.D format was too small for the number to be printed. The decimal may be
      shifted by the "BEST" format.
NOTE: DATA statement used (Total process time):
      real time           0.13 seconds
      cpu time            0.00 seconds


7
8    data test8 ;
9        length a $8 ;
10       a="12345678" ;
11       output ;
12   run ;

NOTE: The data set WORK.TEST8 has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


13
14   data join ;
15       set test8 test10 ;
16   run ;

WARNING: Multiple lengths were specified for the variable a by input data set(s). This can cause
         truncation of data.
NOTE: There were 1 observations read from the data set WORK.TEST8.
NOTE: There were 1 observations read from the data set WORK.TEST10.
NOTE: The data set WORK.JOIN has 2 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds

View solution in original post

3 REPLIES 3
AMSAS
SAS Super FREQ

Compare the variable lengths in the 2 datasets aa and diag
My guess is you have a common variable on both datasets that has different lengths defined.
You might want to run a PROC CONTENTS on them both

Here's a simple example:

data test10 ;
	length a $10 ;
	a="1234567890" ;
	output ;
run ;

data test8 ;
	length a $8 ;
	a="12345678" ;
	output ;
run ;

data join ;
	set test8 test10 ;
run ;

and here's the log:

2    data test10 ;
3        length a $10 ;
4        a="1234567890" ;
5        output ;
6    run ;

NOTE: The data set WORK.TEST10 has 1 observations and 1 variables.
NOTE: At least one W.D format was too small for the number to be printed. The decimal may be
      shifted by the "BEST" format.
NOTE: DATA statement used (Total process time):
      real time           0.13 seconds
      cpu time            0.00 seconds


7
8    data test8 ;
9        length a $8 ;
10       a="12345678" ;
11       output ;
12   run ;

NOTE: The data set WORK.TEST8 has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


13
14   data join ;
15       set test8 test10 ;
16   run ;

WARNING: Multiple lengths were specified for the variable a by input data set(s). This can cause
         truncation of data.
NOTE: There were 1 observations read from the data set WORK.TEST8.
NOTE: There were 1 observations read from the data set WORK.TEST10.
NOTE: The data set WORK.JOIN has 2 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds
bhca60
Quartz | Level 8
Yes, thank you; in one set the icd is $50 and the other is $100. Would I just do the same code only change it to length icd $100?
AMSAS
SAS Super FREQ

Yes, typically you would want to use the length of the longest character variable
If you run the simple test code, you'll notice that the work.join dataset ends up truncating the second observations from "1234567890" to "12345678" (Not Good)

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 3 replies
  • 1556 views
  • 0 likes
  • 2 in conversation