DATA Step, Macro, Functions and more

Multiple lengths were specified for the variable XX by input data set(s)

Reply
Occasional Contributor
Posts: 18

Multiple lengths were specified for the variable XX by input data set(s)

When I try to save a work.dataset as a sas.dataset I get the following warning message:

 

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

 

The dataset (WIO) has 2467 columns (C, D, E etc.) and 36960 rows. IIOdat is the library.

 

Code:

%macro setlist;
%do i=2000 %to 2014;
WIO&i
%end;
%mend setlist;
data IIOdat.WIO;
set %setlist;
run;



 

Log:

58 %macro setlist;
59 %do i=2000 %to 2014;
60 WIO&i
61 %end;
62 %mend setlist;
63
64 data IIOdat.WIO;
65 set %setlist;
66 run;
 
WARNING: Multiple lengths were specified for the variable JU by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable OC by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable SK by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable UO by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable ABA by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable AFI by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable AJQ by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable ALU by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable AQC by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable AUG by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable AWO by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable AYS by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable BAW by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable BFE by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable BHI by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable BJM by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable BNI by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable BNM by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable BNU by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable BSC by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable BWK by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable CHE by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable CJI by input data set(s). This can cause
truncation of data.
WARNING: Multiple lengths were specified for the variable CNL by input data set(s). This can cause
truncation of data.
NOTE: There were 2464 observations read from the data set WORK.WIO2000.
NOTE: There were 2464 observations read from the data set WORK.WIO2001.
NOTE: There were 2464 observations read from the data set WORK.WIO2002.
NOTE: There were 2464 observations read from the data set WORK.WIO2003.
NOTE: There were 2464 observations read from the data set WORK.WIO2004.
NOTE: There were 2464 observations read from the data set WORK.WIO2005.
NOTE: There were 2464 observations read from the data set WORK.WIO2006.
NOTE: There were 2464 observations read from the data set WORK.WIO2007.
NOTE: There were 2464 observations read from the data set WORK.WIO2008.
NOTE: There were 2464 observations read from the data set WORK.WIO2009.
NOTE: There were 2464 observations read from the data set WORK.WIO2010.
NOTE: There were 2464 observations read from the data set WORK.WIO2011.
NOTE: There were 2464 observations read from the data set WORK.WIO2012.
NOTE: There were 2464 observations read from the data set WORK.WIO2013.
NOTE: There were 2464 observations read from the data set WORK.WIO2014.
NOTE: The data set IIODAT.WIO has 36960 observations and 2467 variables.
NOTE: DATA statement used (Total process time):
real time 35.36 seconds
cpu time 11.51 seconds
 
 
What does this mean, and what can I do to fix it?
 
All help is very appreciated!!
 
Contributor
Posts: 35

Re: Multiple lengths were specified for the variable XX by input data set(s)

Posted in reply to biringstad

SAS will look at the first instance of a field and set the ongoing format based on what it sees that first time. If some other value is assigned to that field that is longer it may not fit (say it sees a 5 character field first and then another dataset comes in later and has a 10 character value in that field).

 

It looks like you need to do some data grooming on the datasets you wish to use in the macro, formatting each variable to the same length before setting them together.

Super User
Posts: 11,343

Re: Multiple lengths were specified for the variable XX by input data set(s)

Posted in reply to biringstad

I would place a small wager that all of your WIO&i data sets were created with separate Proc Import statements. Import guesses about the length of variables and if they length changes for values from set to set or the number examined in each proc import (default 20) is small then you get different results.

 

You may be better off going back to the import and use one of the methods to read each file with the same data step.

NOTE: Starting with Excel files often compounds this issue due to the lack of constraints on individual files.

Occasional Contributor
Posts: 18

Re: Multiple lengths were specified for the variable XX by input data set(s)

Posted in reply to biringstad

Thank you for the advises. I ended up changing the code for how I imported the csv files in the beginning of the programme, where I specified the length of the character and numeric variables - It seems like that solved the truncation problem. Thus, in stead of using 'PROC IMPORT' to import multiple csv files, I used the INPUT statement to import the files.

Ask a Question
Discussion stats
  • 3 replies
  • 404 views
  • 0 likes
  • 3 in conversation