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?
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.
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
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.
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.
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?
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.