BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Danglytics
Calcite | Level 5

Hi,

I think this is a simple solution, but I can't seem to figure it out.

I have multiple datasets in the exact same data layout that i'd like to concatenate using the data step.

for example:

data merged ;

set table1 table2 table3 table4 ;

run ;

A variable may have different lengths in each of the tables so when I run the code above I get the warning:

"Multiple lengths were specified for the variable Product by input data set(s). This may cause truncation of data."

I tried adding the length statement but still got the warning.

How can I set the length so I do not get the warning?

Thanks for your help.

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

options varlenchk=nowarn;

View solution in original post

9 REPLIES 9
art297
Opal | Level 21

I can't test this at the moment, but do you still get the error if the place the length statement(s) before the set statement?

Danglytics
Calcite | Level 5

yes the warning still shows up if do:

data merged ;

length product $15 ;

set table1 table2 table3 table4 ;

run ;

art297
Opal | Level 21

How about if, in your set statement, you put the file with the longest lengths first (leftmost) on the list?

data_null__
Jade | Level 19

My limited testing shows that if you still have the warning it means that one or more of the varables from the input data sets have a length longer than you have defined.  You could use PROC CONTENTS and PROC SUMMARY to determine the MAX length of each variable and code gen LENGTH/ATTRIB statements to resolve the issue.

Danglytics
Calcite | Level 5

Is their a way to force the length for the new dataset?

for example:

table1: Product $15

table2: Product $15

table3: Product $17

table4: Product $15

for some reason i have some dirty records in table3 that makes the product variable $17, In my merged dataset I want to make product $15, and its fine if its truncated.

art297
Opal | Level 21

You are doing that with the length statement or by ensuring that the culprit is not the first file.  Or are you asking how to do it without having to confront the warnings?

Danglytics
Calcite | Level 5

yes exactly, is there a way around the warning?

art297
Opal | Level 21

options varlenchk=nowarn;

Danglytics
Calcite | Level 5

Great thanks for your help.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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