BookmarkSubscribeRSS Feed
ayin
Quartz | Level 8

I tried to use the following code to append tables:

data want;
set have1 have2 have3;
run;

and then a warning message pops out:

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

 

The column which has problems is either number or character. I'm wondering if there is a way to tell SAS to automatically use the larger lengths for that column.

3 REPLIES 3
Kurt_Bremser
Super User

First of all, when you have variables of conflicting type (not content!) in your datasets, your data step will fail with an error. So you probably have character variables of differing length that contain numeric and alphanumeric values.

 

To get the maximum length automatically, use the dataset with the longest variable definition first in the set statement.

 

The proper method to handle all this is to make sure from the outset that your variables follow a common definition. Set the correct length upon creation or import from external data sources.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

As @Kurt_Bremser has said, not knowing what structure your data is in comes from not processing it correctly in the first place.  What does your surrouding documentation state - i.e. import agreements, data definition documents, standard working practices, data modelling details etc.  Always be very explicit about everything, that way you never run into these situations.

Ksharp
Super User
proc sql;
create table want as
 select *
  from have1
outer union  corr
 select *
  from have2
outer union  corr
 select *
  from have3
;
quit;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 3359 views
  • 2 likes
  • 4 in conversation