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

Hi SAS Forum,

In the following code, I have introduced the lengths of variables named Account_number, Short_name and country to get rid of the warning message below (SAS Discussion Forum supported me on this, and now no warnings).

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

data k.unified_dataset;

length Account_number $ 32;

length Short_name $ 23;

length country $ 26;

set any_name_1

      any_name_2 (in=inb  rename=(account_name=short_name Net_Write_off_total_USD=balance));

by bank_number account_number current_date;

if inb then Arrears_Band='writoff ';

run;

Question:

Do I need to write the “length” statement thrice? Can I cut short like this…

length Account_number $ 32 Short_name $ 23 country $ 26;

Your help is greatly appreciated.

Thanks

Mirisage

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

IF you are still getting WARNINGS ...

Regardless of whether you have one LENGTH statement or three, that's not solving your problem.  Evidently $23 is not long enough.  Check your PROC CONTENTS results.  You will find one of these (or both):

In ANY_NAME_1, SHORT_NAME already exists and has a length longer than $23.

In ANY_NAME_2, ACCOUNT_NAME has a length longer than $23.

Changing the number of LENGTH statements will not affect the source of this WARNING.  Supplying an adequate length for SHORT_NAME is necessary.

Good luck.

View solution in original post

3 REPLIES 3
art297
Opal | Level 21

Not meaning to sound rude, but couldn't you just have tested that yourself?

In any case, the answer is that you can put them all on one length statement.

SASKiwi
PROC Star

Also without meaning to be rude, this type of question can also be quickly and easily answered by checking the SAS documentation, either in the Help installed with SAS or in the online help. If I have a similar problem I always look there first and if you find the answer it saves time not having to post a question.

Astounding
PROC Star

IF you are still getting WARNINGS ...

Regardless of whether you have one LENGTH statement or three, that's not solving your problem.  Evidently $23 is not long enough.  Check your PROC CONTENTS results.  You will find one of these (or both):

In ANY_NAME_1, SHORT_NAME already exists and has a length longer than $23.

In ANY_NAME_2, ACCOUNT_NAME has a length longer than $23.

Changing the number of LENGTH statements will not affect the source of this WARNING.  Supplying an adequate length for SHORT_NAME is necessary.

Good luck.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1201 views
  • 6 likes
  • 4 in conversation