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;

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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