Learning SAS? Welcome to the exclusive online community for all SAS learners.

Using the %include statement in SAS on Demand for Academics

Reply
Occasional Contributor
Posts: 5

Using the %include statement in SAS on Demand for Academics

I am trying to use the %include statement to bring in two SAS macros into a program I am running in SAS on Demand.  I have my SAS macros stored in the folder /home/myusername/macros.  Two questions:

 

1. I currently have this statement in the program I am running:  %include adjaxis dotplot ;

The two macros I am using are adjaxis.sas and dotplot.sas, both of which ran successfully on an earlier version of SAS (circa 2008).

Is this the correct syntax for the %include statement in SAS on Demand?

 

2. What statements need to be present prior to the %include statement?

 

Super User
Posts: 24,004

Re: Using the %include statement in SAS on Demand for Academics

Posted in reply to rrstarbuck49

@rrstarbuck49 wrote:

 

Is this the correct syntax for the %include statement in SAS on Demand?

 

 


You would usually include the path, which I like to do anyways because then I know exactly where the source code is. You can use an asterisk as a wild card to %include all .sas files in the list. If you don't want all, list the files. 

 

%include '/home/rrstartbuck49/macros/*.sas' ;

@rrstarbuck49 wrote:

 

 

2. What statements need to be present prior to the %include statement?

 


Nothing.

 

Spoiler

@rrstarbuck49 wrote:

I am trying to use the %include statement to bring in two SAS macros into a program I am running in SAS on Demand.  I have my SAS macros stored in the folder /home/myusername/macros.  Two questions:

 

1. I currently have this statement in the program I am running:  %include adjaxis dotplot ;

The two macros I am using are adjaxis.sas and dotplot.sas, both of which ran successfully on an earlier version of SAS (circa 2008).

Is this the correct syntax for the %include statement in SAS on Demand?

 

2. What statements need to be present prior to the %include statement?

 


Occasional Contributor
Posts: 5

Re: Using the %include statement in SAS on Demand for Academics

I put the following statements at the beginning of my SAS program:

%include '/home/rrstarbuck49/macros/dotplot.sas’ ;
%include '/home/rrstarbuck49/macros/adjaxis.sas' ;

I am getting the following error messages in the SAS log:

WARNING: Physical file does not exist, /home/rrstarbuck49/macros/dotplot.sas.
ERROR: Cannot open %INCLUDE file /home/rrstarbuck49/macros/dotplot.sas.
WARNING: Physical file does not exist, /home/rrstarbuck49/macros/adjaxis.sas.
ERROR: Cannot open %INCLUDE file /home/rrstarbuck49/macros/adjaxis.sas.
My file structure is:

Files(Home) main folder
macros subfolder where macros are stores
Adjaxis.sas macros
Dotplot.sas

Any idea about why I am getting these error messages?
Super User
Posts: 24,004

Re: Using the %include statement in SAS on Demand for Academics

Posted in reply to rrstarbuck49

Because SAS thinks the file path is wrong. 


Navigate to the file in the Servers Files & Folders Pane. 

Right click the file, select properties and copy the path from there.  

 


@rrstarbuck49 wrote:
I put the following statements at the beginning of my SAS program:

%include '/home/rrstarbuck49/macros/dotplot.sas’ ;
%include '/home/rrstarbuck49/macros/adjaxis.sas' ;

I am getting the following error messages in the SAS log:

WARNING: Physical file does not exist, /home/rrstarbuck49/macros/dotplot.sas.
ERROR: Cannot open %INCLUDE file /home/rrstarbuck49/macros/dotplot.sas.
WARNING: Physical file does not exist, /home/rrstarbuck49/macros/adjaxis.sas.
ERROR: Cannot open %INCLUDE file /home/rrstarbuck49/macros/adjaxis.sas.
My file structure is:

Files(Home) main folder
macros subfolder where macros are stores
Adjaxis.sas macros
Dotplot.sas

Any idea about why I am getting these error messages?

 

 

SAS Employee
Posts: 21

Re: Using the %include statement in SAS on Demand for Academics

Posted in reply to rrstarbuck49

SAS OnDemand for Academics is linux backed and, as such, is case sensitive.  I suspect that your file names are mixed case.  When saving files, I would encourage you to keep the names lowercase and avoid spaces (substitute '_" for ' ') and special characters ( no parens, ampersands, etc).

 

Another strong suggestion would be to use '~' instead of '/home/<userid>' for paths.   The tilde is shorthand for your home directory.

Ask a Question
Discussion stats
  • 4 replies
  • 276 views
  • 2 likes
  • 3 in conversation