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)

SAS Innovate 2025: Call for Content

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 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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