BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Biffothebear
Calcite | Level 5

Hi there, 

I'm a novice sas user. A past colleague wrote some sas code for me to format some data. The code works but gives a warning, does the code need changing to remove the error?

 

WARNING: THE VARIABLE INFO IN THE DROP, KEEP, OR RENAME LIST HAS NEVER BEEN REFERENCED

 

The warning related to this line of code

 

%looping;

 

which is at the end of the whole code.

 

This is the whole code:

 

%macro weeklyrecon(filename,weeknumber);
data &filename._FINAL;
set &filename.;
Start_Date= input(put(&starting_date.,8.),yymmdd8.);
file_date=Start_date+(&weeknumber.-1)*7;
format file_date ddmmyy10.;
File_Document_Number=&weeknumber;
abc_cost_ID=substr(F1,95,18);
abc=substr(f1,95,10);
cost_ID=substr(f1,105,8);
analysis_1=substr(f1,113,3);
analysis_2='';
analysis_3='';
Amount=substr(f1,116,15)*1;
Sign=substr(f1,131,1);
if sign="+" then DSValue=Amount/100;
else if sign="-" then DSValue=-Amount/100;
format DSValue 15.2;
Analysis5='Weekly';
Analysis6Date='';
Analysis4=compress(substr(f1,134,3),'!@#',' ');
drop f1 info sign amount start_date;
run;
 
proc sort data=&filename._FINAL;
by descending Analysis4;
run;
 
%mend;
 
%macro looping;
%do i=1 %to &filenum.;
%let prefix=weekly_;
%let weekly_n=&prefix.&i.;
%put &&weekly_n.;
%weeklyrecon(&weekly_n.,&i.);
%end;
%mend looping;
 
%looping;

 

 

Many thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

It's a WARNING not an ERROR which means it's "ugly" but your code will still fully execute. 

 

You get this warning because in your code you attempt to DROP a variable that doesn't exist.  Variable INFO doesn't get created in your data step and it obviously also doesn't pre-exist in your input table &filename.

Patrick_0-1696555521162.png

You could just remove INFO from your drop statement. 

View solution in original post

3 REPLIES 3
Patrick
Opal | Level 21

It's a WARNING not an ERROR which means it's "ugly" but your code will still fully execute. 

 

You get this warning because in your code you attempt to DROP a variable that doesn't exist.  Variable INFO doesn't get created in your data step and it obviously also doesn't pre-exist in your input table &filename.

Patrick_0-1696555521162.png

You could just remove INFO from your drop statement. 

Biffothebear
Calcite | Level 5
Thanks very much, that worked by removing INFO.
Patrick
Opal | Level 21

@Biffothebear Just fyi: SAS system option DKROCOND allows you to change how SAS behaves if dropping a non existent variable.

I'm of the opinion that one should write code that doesn't get into such a situation but just in case below a code sample how you could suppress the warning.

/* store current setting for option dkrocond in macro variable &sv_dkrocond */
%let sv_dkrocond=%sysfunc(getoption(dkrocond,keyword));
/* set option to nowarning */
options dkrocond=nowarning;

data have;
  set sashelp.class;
  drop VarDoesNotExist;
run;

/* restore dkrocond to previous value */
options &sv_dkrocond;

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 3 replies
  • 1324 views
  • 1 like
  • 2 in conversation