Write and run SAS programs in your web browser

WARNING when using %include

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 12
Accepted Solution

WARNING when using %include

Hi,

 

I'm trying to learn about using %include and am starting off by simply trying to use it to invoke a short piece of code referencing five libnames.

 

The code itself is: -

 

/* LIBS */
libname results '/folders/myfolders/hr/datasets/results';
libname datasets '/folders/myfolders/hr/datasets/datasets';
libname temp '/folders/myfolders/hr/datasets/temp_results';
libname testing '/folders/myfolders/hr/datasets/testing';
libname user '/folders/myfolders/hr/datasets/user';

 

and my %include statement is: -

 

%include '/folders/myfolders/HR/Code/Systems/Testing/Testing Macros - Y2/Testing - Libs & Dates.sas';

 

When I run this, the log displays: -

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
WARNING: Apparent invocation of macro INCLUDE not resolved.
WARNING: Apparent invocation of macro INCLUDE not resolved.
61
62 %include '/folders/myfolders/HR/Code/Systems/Testing/Testing Macros - Y2/Testing - Libs & Dates.sas';
NOTE: Libref RESULTS was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/hr/datasets/results
NOTE: Libref DATASETS was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/hr/datasets/datasets
NOTE: Libref TEMP was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/hr/datasets/temp_results
NOTE: Libref TESTING was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/hr/datasets/testing
NOTE: Libref USER was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/hr/datasets/user
92
93 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
106

 

The code does have the desired effect (it successfuly assigns the libs) but I'd be interested to understand why it produces the two identical warnings. I have tried searching online but have not been able to identify the solution so any suggestions would be gratefully received.

 

Many thanks,

Rob

 

 

 


Accepted Solutions
Solution
2 weeks ago
Super User
Super User
Posts: 6,706

Re: WARNING when using %include

[ Edited ]

That line is how SAS/Studio let's your SAS program know the name of the file that you are running.

It is probably not a good idea to have '%include' as part of your filename! Or other macro triggers like &.

 

View solution in original post


All Replies
Super User
Super User
Posts: 7,565

Re: WARNING when using %include

Not sure I follow.  You put the libnames in a text file called Testing - Libs & Dates.sas, yes?  And store this at "/folders/myfolders/HR/Code/Systems/Testing/Testing Macros - Y2/"

Then in your code window, without any other code you run the statement:

%include '/folders/myfolders/HR/Code/Systems/Testing/Testing Macros - Y2/Testing - Libs & Dates.sas';

Yes?  If so then the log your posted is wrong, included statements appear with a + symbol before them.  Please post the code exactly as you are running it.

Super User
Posts: 7,110

Re: WARNING when using %include

You have an incorrectly written %include() (note the brackets) before your %include that works, probably in code to be sent before every execution. SAS assumes this to be a macro call and not a macro statement. Since no such macro is defined, you get the WARNING.

 

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 12

Re: WARNING when using %include

Thanks for the responses and please forgive my ignorance but I'm struggling to get my head round either of them. 

 

What I posted in my original question is exactly what my log has displayed (I've attached snips of the %include, the code to be included and the log to evidence this).

 

And the only %include I have is the one prior to the location of the code I want to include so I don't see how I can have an incorrectly written %include() before my %include. This is the only code I have run since opening SAS so I couldn;t have run anything previsouly that had another %include() in it.

 

Are you able to explain any further?

 

Thanks

Super Contributor
Posts: 321

Re: WARNING when using %include

Is there an include in your autoexec file?

Occasional Contributor
Posts: 12

Re: WARNING when using %include

Hi Chris,

 

I don't have an autoexec file so no.

 

Whether it makes a differnce or not I don't know but I'm actually using SAS University Edition rather than SAS Studio, the two seem to be used interchangably hence my putting it in the 'SAS Studio' board s oapologies if I've misled anyone.

Super Contributor
Posts: 321

Re: WARNING when using %include

SAS University Edition is a version of SAS which uses SAS Studio as it's interface so in practice they are used pretty much interchangeably although technically they're not the same thing.

 

The autoexec in SAS Studio (University Edition) can be found by clicking a button to the right of the words "SAS Programmer" in the top right hand corner of the screen. that opens a context menu one option of which is "Edit Autoexec File". It might be worth checking that just in case something has crept in there....

Super User
Super User
Posts: 6,706

Re: WARNING when using %include

[ Edited ]

The warning is NOT caused by the code you are running, but by the code that SAS/Studio submitted for you but hid in the log.

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
WARNING: Apparent invocation of macro INCLUDE not resolved.
WARNING: Apparent invocation of macro INCLUDE not resolved.
61
62 %include '/folders/myfolders/HR/Code/Systems/Testing/Testing Macros - Y2/Testing - Libs & Dates.sas';

Notice that the warning is coming BEFORE the first line of your actual program.

In SAS/Studio you can change your preferences so the lines of code that SAS/Studio submits will appear in the log also.

image.png

If you don't see anything in there then try resetting your SAS session (another menu item in SAS/Studio interface) and see if you still get the error message on the first submit.  If not then perhaps something about your code is leaving SAS in state that it is confused and the commands that SAS/Studio sends before/after submitting your code is getting impacted by that.  For example your code might have unbalanced quotes or parentheses.

 

One quick thing to try is to add the LINESIZE= option to your %INCLUDE statement. Perhaps you have mistakenly created a text file with lines that are longer than the default line length that SAS uses for including code and so the ends of some statements are not being seen.

%include 'my file name' / linesize=32767 ;

In general it is good coding practice to create code files wth lines of 75 characters or less.  Longer lines make the program difficult for humans to read, just like the way that newspapers use multiple narrow columns of text on a wide page to make it easier to read.

Occasional Contributor
Posts: 12

Re: WARNING when using %include

Many thanks for the help.

 

I checked the autoexec and there was nothing in there.

 

I have enabled the 'Show generated code in the SAS log' preference and in the log it shows: -

 

22 %LET _SASPROGRAMFILE = %BQUOTE(/folders/myfolders/HR/Code/Systems/Testing/Testing Macros - Y2/Test Macro/Testing -
22 ! %include.sas);
WARNING: Apparent invocation of macro INCLUDE not resolved.
WARNING: Apparent invocation of macro INCLUDE not resolved.
23 %LET _BASEURL = %BQUOTE(http://localhost:10080/SASStudio/);

 

and to my untrained eye, it appears that there is a system generated macro that is referencing the %include code but I will need to investigate further to get to the bottom of what is going on.

 

Thanks again for the suggestions and guidance,


Regards,

Rob

Solution
2 weeks ago
Super User
Super User
Posts: 6,706

Re: WARNING when using %include

[ Edited ]

That line is how SAS/Studio let's your SAS program know the name of the file that you are running.

It is probably not a good idea to have '%include' as part of your filename! Or other macro triggers like &.

 

Occasional Contributor
Posts: 12

Re: WARNING when using %include

Thanks Tom / Kurt,

 

I've taken the % out of the file name and am no longer getting the warning.

 

Much appreciated,

Rob

Super User
Posts: 7,110

Re: WARNING when using %include

Filenames for programs and data should contain letters from the western alphabet, digits, underlines, dashes and dots, BUT NOTHING ELSE!

Ampersands will send jobs into the background on UNIX systems, percents can be misinterpreted by Windows as environment variable names, both are macro triggers for SAS. Asterisks, slashes, backslashes, dollar signs etc. all carry special meanings in different operating systems, and blanks are the natural separators. Don't use any of these.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 11 replies
  • 229 views
  • 2 likes
  • 5 in conversation