BookmarkSubscribeRSS Feed
sanalitics
Obsidian | Level 7

Hello,

Even though I update the

options varlenchk=nowarn;

I am still receiving warning:

Program

options varlenchk=nowarn;

data a;

input name $10.;

cards;

asd

;

run;

data b;

input name $5.;

cards;

asd1

;

run;

proc append base=a data=b;run;

Log:

NOTE: Appending WORK.B to WORK.A.

WARNING: Variable name has different lengths on BASE and DATA files (BASE 10 DATA 5).

NOTE: There were 1 observations read from the data set WORK.B.

NOTE: 1 observations added.

9 REPLIES 9
RW9
Diamond | Level 26 RW9
Diamond | Level 26

You may need the force and nowarn options on the proc append rather than the options statement:

Base SAS(R) 9.2 Procedures Guide

However, I would be more worried about why you have two variables which are ostensibly the "same", but have differing lengths?  I would investigate and fix the problem yourself before appending.  It oftens happens when people let proc import guess their data for instance, don't write an import procedure and fix lengths of the data you know.  When creating variables don't let SAS guess the best length, set it yourself, again you know your data.

SASKiwi
PROC Star

This option only applies to SET, MERGE, UPDATE, or MODIFY statements not APPEND:

http://support.sas.com/kb/37/102.html

data_null__
Jade | Level 19

The OP can use MODIFY to APPEND.

sanalitics
Obsidian | Level 7

I have the warning even after running the following code:

proc append base=a data=b force nowarn;run;

LOG:

21        

22         GOPTIONS ACCESSIBLE;

23         proc append base=a data=b force nowarn;run;

NOTE: Appending WORK.B to WORK.A.

WARNING: Variable name has different lengths on BASE and DATA files (BASE 10 DATA 5).

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Ok, reading further, nowarn only seems to supress the warning if variable is only in one.  My recommendation, fix the length issue at source or prior to the append.  The errors and warnings are there to stop you from doing this in the first place.  If you still insist on forging ahead:

proc sql;

     create table WANT as

     select * from a.data

     union all

     select * from b.data;

quit;

sanalitics
Obsidian | Level 7

I need an option to the existing solution... I dont want to make any changes in the code or logic. Kindly let me know if there are any options which can be patched into config or autoexec file to make it global.

LinusH
Tourmaline | Level 20

Suppress errors/warnings is not a best practice.

Having control of your data is.

Data never sleeps
sanalitics
Obsidian | Level 7

I agree with you...but when we know the category of the warning such as

because of variable length we could ignore and an example from SAS is:

options varlenchk=nowarn;

I just need to ignore the warning from this statement because of the differences in the length.

Kurt_Bremser
Super User

Don't put a bandaid on the rusty hole in your ship's bottom.

Meaning: fix your data and make your code work right.

You can't expect things to change by doing nothing.

Does this mean work? By $DEITY, YES! Remember you're getting paid for it. In money or university credentials.

And every minute you spend now in improving your code will save hours in the future.

I can spend a lot of time here giving (more or less) clever advice because my codes have been improved, through many tedious hours of work, to a point where maintenance is a breeze.

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
  • 5178 views
  • 1 like
  • 6 in conversation