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.

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!

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.

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