DATA Step, Macro, Functions and more

Autoexec.sas not running

Reply
Occasional Contributor
Posts: 18

Autoexec.sas not running

Hello,

 

I'm trying to setup a simple autoexec file for a project I'm working on. I'm using SAS 9.4 in a 64-bit Windows environment. I open SAS by double clicking on the program I want to use/edit.

 

I have saved a file called autoexec.sas in the same directory as the programs that I want to work on, yet when I open those programs the autoexec.sas program is not executing. I have checked the config file and the autoexec option is not specified which I believe means it will default to looking for one, starting with the current folder.

 

Am I missing something?

Super User
Posts: 7,845

Re: Autoexec.sas not running

Look here how SAS looks for autoexec.sas files on Windows.

SAS will pick up the autoexec file in your program directory only if you cd there first before starting SAS.

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

Re: Autoexec.sas not running

Posted in reply to KurtBremser
  • If you start SAS by double-clicking a .SAS program file from Windows Explorer, the default current folder is the path to the operating system with \system32 appended to it. An example of a default current folder under Windows NT and Windows XP is C:\winnt\system32.

 

OK, so SAS is searching for the autoexec in the path to the operating system.

 

How do I tell it to look in the directory where I open the program from? Also, I want to use different autoexecs for different projects. I.e. different autoexecs for programs opened in different locations. Is that possible?

 

Thanks

Occasional Contributor
Posts: 18

Re: Autoexec.sas not running

Posted in reply to KurtBremser

Is this definitely the case? I thought the current folder was the path displayed in the bottom right of the SAS console? When I double click on a .sas program to open SAS the path displayed there is same location where I double clicked on the program.

Super User
Posts: 7,845

Re: Autoexec.sas not running

That is the path to the .sas file, but not the path SAS was started from. That is determined by the definition of "SAS" used in Windows to link the .sas files to. And that is (AFAIK) the SASFoundation/version subdir in SASHOME.

In UNIX I'd create a shell script replacement for the SAS executable that checks the commandline, and if a program is found in there, extracts the path from that and scans for a autoexec.sas there. But in UNIX one would usually navigate to the path first and then start SAS, and that for batch runs.

 

Since you were talking about projects in the other post, why not use the autoexec feature in SAS Enterprise Guide? There you have an automatic process flow within a project file that is automatically executed.

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

Re: Autoexec.sas not running

Posted in reply to KurtBremser

I see. My terminology is a bit clumsy above, I'm using enhanced editor not EG. By project I just mean what I'm working on.

 

Does anyone know how to specify the autoexec location in Windows?

Super User
Super User
Posts: 7,074

Re: Autoexec.sas not running

I haven't done this in years, but you used be able to tell Windows what action to perform when you double click on a file of a specific type.

 

So it sounds like you to make your own command. Not sure if it can be done as a single command string or if you need to create batch file or a  powershell or VB program.

 

There are two ways you would want this program to work. The easiest would be to CD to the folder of the program file and then launch SAS.  But watch out for files on D/E/F/.... drives.  Also that will not work for files on network shares that are not mapped to a drive letter.

 

The other way would be to check if there exists an autoexec.sas file in that folder and then add the -autoexec option to the command that starts SAS.  

Ask a Question
Discussion stats
  • 6 replies
  • 83 views
  • 0 likes
  • 3 in conversation