BookmarkSubscribeRSS Feed
DGrint
Obsidian | Level 7

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?

6 REPLIES 6
Kurt_Bremser
Super User

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.

DGrint
Obsidian | Level 7
  • 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

DGrint
Obsidian | Level 7

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.

Kurt_Bremser
Super User

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.

DGrint
Obsidian | Level 7

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?

Tom
Super User Tom
Super User

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.  

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 6 replies
  • 2631 views
  • 0 likes
  • 3 in conversation