The SAS Output Delivery System and reporting techniques

options varlenchk=nowarn not working for proc append

Reply
Occasional Contributor
Posts: 11

options varlenchk=nowarn not working for proc append

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.

Esteemed Advisor
Esteemed Advisor
Posts: 6,698

Re: options varlenchk=nowarn not working for proc append

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.

Respected Advisor
Posts: 2,908

Re: options varlenchk=nowarn not working for proc append

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

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

Respected Advisor
Posts: 3,768

Re: options varlenchk=nowarn not working for proc append

The OP can use MODIFY to APPEND.

Occasional Contributor
Posts: 11

Re: options varlenchk=nowarn  not working for proc append

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).

Esteemed Advisor
Esteemed Advisor
Posts: 6,698

Re: options varlenchk=nowarn  not working for proc append

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;

Occasional Contributor
Posts: 11

Re: options varlenchk=nowarn  not working for proc append

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.

Esteemed Advisor
Posts: 5,081

Re: options varlenchk=nowarn  not working for proc append

Suppress errors/warnings is not a best practice.

Having control of your data is.

Data never sleeps
Occasional Contributor
Posts: 11

Re: options varlenchk=nowarn  not working for proc append

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.

Esteemed Advisor
Posts: 5,956

Re: options varlenchk=nowarn  not working for proc append

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Post a Question
Discussion Stats
  • 9 replies
  • 1373 views
  • 1 like
  • 6 in conversation