BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JohnT
Quartz | Level 8
Gday,

I want to remove all error/warning messages from my code.

I have a pretty simple piece of code, where the STATE have been defined with different lengths.

1490
1491 DATA WPolSummary0;
1492 format state $5.;
1493 SET
1494 rateBusPack
1495 rateISR
1496 rateBW
1497 rateCAR
1498 ;
1499 RUN;

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

NOTE: There were 95507 observations read from the data set WORK.RATEBUSPACK.
NOTE: There were 1822 observations read from the data set WORK.RATEISR.
NOTE: There were 70663 observations read from the data set WORK.RATEBW.
NOTE: There were 19263 observations read from the data set WORK.RATECAR.
NOTE: The data set WORK.WPOLSUMMARY0 has 187255 observations and 32 variables.
NOTE: DATA statement used (Total process time):
real time 2.98 seconds
cpu time 0.96 seconds

^^

The offending dataset is WORK.RATEBW, the length is $255 whereas the rest have been defined as $5.

In this dataset, how can I define the length to a smaller number than the largest value, eg $5?

I have observed that if I specify a larger number, eg $500, there are no errors, but I know that the STATE values are never longer than five character.

I don't want to create a new variable and re-allocate the values.

I don't want to use system options eg VARLENCHK=.


Thanks.


edit:
I should say that I'm using SAS 9.2 on Windows

Message was edited by: John T Message was edited by: John T
1 ACCEPTED SOLUTION

Accepted Solutions
JohnT
Quartz | Level 8
Hi Scott,

Thanks for your response, but I don't want that solution.

For the time being, this was my solution:

DATA WPolSummary0;
length state $500. state2 $5.;
SET
rateBusPack
rateISR
rateBW
rateCAR
;

state2 = state;
drop state;
rename state2 = state;
RUN;

^^

Which is essentially, what you suggested.

I don't want to perform renaming of variables, if I can get away with it. Any other ideas?

View solution in original post

9 REPLIES 9
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Suggest you use a RENAME=(=) as a SET "data set" option, and then perform an INPUT function in an assignment statement to get the desired result without the WARNING message.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

length difference rename dataset option site:sas.com
JohnT
Quartz | Level 8
Hi Scott,

Thanks for your response, but I don't want that solution.

For the time being, this was my solution:

DATA WPolSummary0;
length state $500. state2 $5.;
SET
rateBusPack
rateISR
rateBW
rateCAR
;

state2 = state;
drop state;
rename state2 = state;
RUN;

^^

Which is essentially, what you suggested.

I don't want to perform renaming of variables, if I can get away with it. Any other ideas?
SASKiwi
PROC Star
I suspect you are using SAS 9.2 and the VARLENCHK system option is set to WARN. If you want to turn off the warning try:

options VARLENCHK = NOWARN;

This is the default SAS 9.1.3 behaviour.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
So, do also consider that by setting the VARLENCHK option to NOWARN, you may be masking another possible problem symptom condition that could go unnoticed. I suggest you reconsider the RENAME= approach without limiting yourself with the NOWARN approach. I have similar recommendations for using SAS OPTIONS DKRICOND / DKROCOND with NOWARN as well.

Scott Barry
SBBWorks, Inc.
rmoreno
Fluorite | Level 6

Maybe Scott refered to something like this, which I usually use for adapting dates to Excel format and somehow prefer as more beautiful:

 

DATA WPolSummary0 (DROP=state_old);
length state $5.;
SET
rateBusPack
rateISR
rateBW (RENAME=(state=state_old))
rateCAR
;

state=state_old;
RUN;

Cheers!
(Is this actually used as a "goodbye"? Best wishes or best regards maybe sounds  like "too much" here ^^)

JohnT
Quartz | Level 8
Hi,

Thanks, I honestly did not expect a solution, I trawled google for an hour looking for one.

As Scott mentioned, I don't want to use that system option, as it will hide the real errors.

Really, I just wanted to make beautiful code. That and remove error/warning messages in the code, so when other people in the team run it, they aren't falsely alerted to issues.

The use of the rename statement, whilst it works, in this case, I would no regard as beautiful. For the time being it is what I'm using.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Okay - whatever steers your mouse-cursor.....beautiful, efficient, well-documented or otherwise operational....

Scott Barry
SBBWorks, Inc.
ArtC
Rhodochrosite | Level 12
Assuming that you have control (don't we all wish for just such a thing?) of the creation of the incoming data sets, beautiful code would require cleaning up, assigning the correct length to STATE, in the data set WORK.RATEBW. Then the whole problem goes away.
martha_sas
SAS Employee
If you don't mind that the variable state is stored with length 255 in the WPolSummary, and if you don't need the rate* data sets to be in any particular order in the set statement, you can also just switch around the data set names so that rateBW is first in the set statement.

set rateBW rateBusPack rateISR rateCAR;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 43716 views
  • 1 like
  • 6 in conversation