I'm tired of manually navigating to the current working folder and would like to create a hotkey in SAS to get me there. I have designed a command to open the current folder from within SAS. However, I cannot get it to execute via a hotkey.
I have created (stolen) the macro:
%macro GetPwd();
%qsubstr(
%sysget(SAS_EXECFILEPATH)
, 1
, %length(%sysget(SAS_EXECFILEPATH))-%length(%sysget(SAS_EXECFILENAME))
)
%mend;
I have saved the above as GetPwd.sas
in my autocall library.
In interactive mode, I can then use the following to open Windows Explorer to the current SAS working folder:
/*The Call:*/
%sysexec(start explorer.exe "%GetPwd()" && exit);
The problem arises when I place the above call in the KEYS
menu.
When I issue the call via the hotkey (SHF F9
), Windows Explorer opens to "Computer" and I get the following error in SAS:
WARNING: Argument 2 to macro function %QSUBSTR is out of range.
WARNING: Argument 3 to macro function %QSUBSTR is out of range.
Why does this error occur when the call is issued from a hotkey and not occur when submitted via the editor?
I have had success with the similar task of opening the SAS Temporary folder location using:
%sysexec(start explorer.exe "%sysfunc(pathname(work))" && exit);
See F9
in the KEYS
menu image above.
%sysexec
call directly in the macro routine and assigning it to the shortcut, c.g.submit '%OpenPwd;'
– Dominic Comtois