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.
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.
This option only applies to SET, MERGE, UPDATE, or MODIFY statements not APPEND:
The OP can use MODIFY to 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).
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;
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.
Suppress errors/warnings is not a best practice.
Having control of your data is.
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.
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.