Dear community!
Is there any repository/collection of the omnipresent auto call macros deliverd with the indivual products?
To clarify my question: I do know how to list macros available in sasautos option/paths ... I do know how to get a source listing of those individually ... I do know how to download individual macros to my local client.
My question is aming at having them downloaded in batch, most prefereably via some git mechanism. So is there any publicly available source to have them all on local disk? The underying objective is - you may have guessed it - to use UNIX tools to search/"grep" through their source for keywords as there is no documentation on them available ...
Cheers
fja
Being stuck with using Enterprise Guide instead of having access to a real computer is a pain.
You can create simple SAS code to copy the source code to the SAS log or some other place where you can look at it. If SAS is running on Windows then it is normally very easy as you should have a SASAUTOS fileref defined.
884 data _null_; 885 infile sasautos(tslit.sas); 886 input; 887 put _infile_; 888 run; NOTE: The infile library SASAUTOS is: Directory=('C:\Program Files\SASHome\SASFoundation\9.4\core\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\aacomp\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\accelmva\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\assist\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\dmscore\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\eis\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\ets\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\graph\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\hps\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\iml\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\mlearning\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\or\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\qc\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\share\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\stat\sasmacro') NOTE: The infile SASAUTOS(tslit.sas) is: Filename=C:\Program Files\SASHome\SASFoundation\9.4\core\sasmacro\tslit.sas, RECFM=V,LRECL=32767,File Size (bytes)=3509, Last Modified=07Sep2017:00:11:06, Create Time=05May2022:12:17:21 /*--------------------------------------------------------------------- * * SAS TEST LIBRARY * * NAME: tslit.sas * TITLE: %tslit - puts single quotes around input value * INPUT: * OUTPUT: none * SPEC.REQ: * SUPPORT: flash - gordon Keener * domcge - Don McGee - Dev Testing Austin (DTA) * 04May06 domcge - updated macro with Gordon Keener's version. *-------------------------------------------------------------------*/ /********************************************************************* NAME: tslit FUNCTION: puts single quote around the input value. This comes in useful when needing to evaluate a macro variable and at the same time put singe quotes (') around the value. For example: %put %tslit(test); --- will output 'test' to the log %put %tslit(&SYSHOSTNAME); --- will output the value in &SYSHOSTNAME in single quotes, ie. 'rdaw3squad' An example in PROC TSSQL: proc tssql; CREATE TABLE tab1(var1 CHAR(10)); INSERT INTO tab1 VALUES(%tslit(&SYSHOSTNAME)); --- The following will produce an error because it --- --- it thinks it is looking for a column name. --- INSERT INTO tab1 VALUES("&SYSHOSTNAME"); SELECT * FROM tab1; DROP TABLE tab1; quit; The log: 31 proc tssql; 32 CREATE TABLE tab1(var1 CHAR(10)); NOTE: Execution succeeded. No rows affected. 33 34 INSERT INTO tab1 VALUES(%tslit(&SYSHOSTNAME)); NOTE: Execution succeeded. One row affected. 35 36 INSERT INTO tab1 VALUES("&SYSHOSTNAME"); ERROR: Column not found ERROR: column "rdaw3squad" not found 37 38 SELECT * FROM tab1; VAR1 ---------- rdaw3squad 39 40 DROP TABLE tab1; NOTE: Execution succeeded. No rows affected. 41 quit; NOTE: PROCEDURE TSSQL used (Total process time): real time 0.25 seconds cpu time 0.23 seconds **********************************************************************/ /********************************************************************* * This version of the macro was provided by Gordon Keener. It will * * work in the datastep because it unquotes the result at the end. * * It also uses the datastep function quote to added the necessary * * values to the input value. * *********************************************************************/ %macro tslit(value); %local s1 s2 v1 v2 v3; /* S1337780: Check for NULL string */ %if %length(&value)=0 %then %do; '' %end; %else %do; %let s1 = %str(%'%"); %let s2 = %str(%"%'); %let v1 = %qsysfunc(translate(&value, &s1, &s2)); %let v2 = %qsysfunc(quote(&v1)); %let v3 = %qsysfunc(translate(&v2, &s2, &s1)); %unquote(&v3) %end; %mend; NOTE: A total of 105 records were read from the infile library SASAUTOS. The minimum record length was 0. The maximum record length was 81. NOTE: 105 records were read from the infile SASAUTOS(tslit.sas). The minimum record length was 0. The maximum record length was 81. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.00 seconds
On Unix if SASAUTOS fileref is not defined for you it is easy enough to define as on Unix they normally store all of the autocall macros into a single directory instead of the gazillion individual directories they used on PC-SAS. So if the SASAUTOS fileref is not defined you can make it yourself.
%if %sysfunc(fileref(sasautos)) %then %do;
filename sasautos '!SASROOT/sasautos';
%end;
Other points:
Run this line of code
%put %sysfunc(getoption(sasautos));
In the log you will see something that looks like this (for SAS/Studio on Unix)
( "SASEnvironment/SASMacro" '!SASROOT/forecastbat/sasmacro' '!SASROOT/sasautos' )
So three folders are shown (on Windows or other operating systems, there may not be 3), you want to search each of these folders.
Hello Paige!
Thank you very much for your quick reply ...
Yes, I am aware of how to find the macros on my system and I can query their indivudual source ... but is there a repository or something like a "golden source" available?
Cheers
Fja
The phrase "golden source" is not meaningful to me, I don't understand.
I also am not clear on the goal here, if you know the folders the macros are stored in, you could GREP those folders. I'm not sure why anything more than that is needed.
@PaigeMiller wrote:
I also am not clear on the goal here, if you know the folders the macros are stored in, you could GREP those folders. I'm not sure why anything more than that is needed.
Well, my environment is currently quite limited. Those files are located on a sas server where I cannot log on directly (nor open a shell), i.e. I do not have direct access to the SASROOT folder. I just can run EG (without any local sas server) the only way to sift through them is to copy them onto my local pc.
Of course I can help myself by writing some macros that list the available files and query their contents. But this is tedious. Another reason for my question is, that I expect these macros to evolve over time. So I'd be interested in the latest version along with the history ... not just that version that got installed with the distribution.
Does that help to clarify my point?
Cheers
The macros are installed when SAS is installed. There is no need to "download" them anywhere.
@Tom wrote:
The macros are installed when SAS is installed. There is no need to "download" them anywhere.
Hello Tom!
Thank you for your reply. I agree as long it is just about using them. If you want to alter them or investigate them you might very well feel the need to have a local copy. I have detailed my environment in reply to Paige's post above. Maybe this helps to understand, why I am asking ...
Cheers
Being stuck with using Enterprise Guide instead of having access to a real computer is a pain.
You can create simple SAS code to copy the source code to the SAS log or some other place where you can look at it. If SAS is running on Windows then it is normally very easy as you should have a SASAUTOS fileref defined.
884 data _null_; 885 infile sasautos(tslit.sas); 886 input; 887 put _infile_; 888 run; NOTE: The infile library SASAUTOS is: Directory=('C:\Program Files\SASHome\SASFoundation\9.4\core\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\aacomp\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\accelmva\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\assist\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\dmscore\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\eis\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\ets\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\graph\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\hps\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\iml\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\mlearning\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\or\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\qc\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\share\sasmacro' 'C:\Program Files\SASHome\SASFoundation\9.4\stat\sasmacro') NOTE: The infile SASAUTOS(tslit.sas) is: Filename=C:\Program Files\SASHome\SASFoundation\9.4\core\sasmacro\tslit.sas, RECFM=V,LRECL=32767,File Size (bytes)=3509, Last Modified=07Sep2017:00:11:06, Create Time=05May2022:12:17:21 /*--------------------------------------------------------------------- * * SAS TEST LIBRARY * * NAME: tslit.sas * TITLE: %tslit - puts single quotes around input value * INPUT: * OUTPUT: none * SPEC.REQ: * SUPPORT: flash - gordon Keener * domcge - Don McGee - Dev Testing Austin (DTA) * 04May06 domcge - updated macro with Gordon Keener's version. *-------------------------------------------------------------------*/ /********************************************************************* NAME: tslit FUNCTION: puts single quote around the input value. This comes in useful when needing to evaluate a macro variable and at the same time put singe quotes (') around the value. For example: %put %tslit(test); --- will output 'test' to the log %put %tslit(&SYSHOSTNAME); --- will output the value in &SYSHOSTNAME in single quotes, ie. 'rdaw3squad' An example in PROC TSSQL: proc tssql; CREATE TABLE tab1(var1 CHAR(10)); INSERT INTO tab1 VALUES(%tslit(&SYSHOSTNAME)); --- The following will produce an error because it --- --- it thinks it is looking for a column name. --- INSERT INTO tab1 VALUES("&SYSHOSTNAME"); SELECT * FROM tab1; DROP TABLE tab1; quit; The log: 31 proc tssql; 32 CREATE TABLE tab1(var1 CHAR(10)); NOTE: Execution succeeded. No rows affected. 33 34 INSERT INTO tab1 VALUES(%tslit(&SYSHOSTNAME)); NOTE: Execution succeeded. One row affected. 35 36 INSERT INTO tab1 VALUES("&SYSHOSTNAME"); ERROR: Column not found ERROR: column "rdaw3squad" not found 37 38 SELECT * FROM tab1; VAR1 ---------- rdaw3squad 39 40 DROP TABLE tab1; NOTE: Execution succeeded. No rows affected. 41 quit; NOTE: PROCEDURE TSSQL used (Total process time): real time 0.25 seconds cpu time 0.23 seconds **********************************************************************/ /********************************************************************* * This version of the macro was provided by Gordon Keener. It will * * work in the datastep because it unquotes the result at the end. * * It also uses the datastep function quote to added the necessary * * values to the input value. * *********************************************************************/ %macro tslit(value); %local s1 s2 v1 v2 v3; /* S1337780: Check for NULL string */ %if %length(&value)=0 %then %do; '' %end; %else %do; %let s1 = %str(%'%"); %let s2 = %str(%"%'); %let v1 = %qsysfunc(translate(&value, &s1, &s2)); %let v2 = %qsysfunc(quote(&v1)); %let v3 = %qsysfunc(translate(&v2, &s2, &s1)); %unquote(&v3) %end; %mend; NOTE: A total of 105 records were read from the infile library SASAUTOS. The minimum record length was 0. The maximum record length was 81. NOTE: 105 records were read from the infile SASAUTOS(tslit.sas). The minimum record length was 0. The maximum record length was 81. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.00 seconds
On Unix if SASAUTOS fileref is not defined for you it is easy enough to define as on Unix they normally store all of the autocall macros into a single directory instead of the gazillion individual directories they used on PC-SAS. So if the SASAUTOS fileref is not defined you can make it yourself.
%if %sysfunc(fileref(sasautos)) %then %do;
filename sasautos '!SASROOT/sasautos';
%end;
Other points:
@Tom wrote:
Being stuck with using Enterprise Guide instead of having access to a real computer is a pain.
Ooooh yes!
Hello Tom!
Thank you for your kind remarks ... as none of the most experienced users here seems to know about a repository, I think the procedure you suggested is the road to go down ... along with Patrick's ( @Patrick )suggestions ...
Other points:
- They do not change the autocall macro very often.
- If you are using Enterprise Guide (or SAS/Studio) to submit your code then there are other macros that are defined by that interface. Finding the source for those is MUCH harder.
- Some are just ancient and so do not take advantage of advances in SAS features. For example the %TSLIT() macro just could just be replaced with this function call: %sysfunc(quote(%superq(value),%str(%')))
True. Thank you for pointing this out ...
Cheers
Fja
Hi.
Are you trying to download the autocall macros (which are SAS programs)? If yes, have you considered the following:
https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/connref/n0da63bm99moq3n1ht2dmxliwydb.htm
@john_mccall wrote:Are you trying to download the autocall macros (which are SAS programs)? If yes, have you considered the following:
https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/connref/n0da63bm99moq3n1ht2dmxliwydb.htm
Hello!
Thank you for your reply John. Well downloading them in batch is one possible solution. Alas, I do not have a local sas server running and SAS/connect cannot be used to copy to an arbritary machine, can it? (At least as far as I know it.)
I am happy to learn, if this is different. 🙂
Cheers
With a few tweaks to Tom's code you can write all the code to a file that you store on your server and then download this file via EG.
The ootb SAS macros are mostly rather "oldish". I use only few of them (like %tslit or the metadata security macros - which are documented). You certainly shouldn't modify them - or then store the modified version under a different name in a site specific SAS Autocall macro library.
@Patrick wrote:
With a few tweaks to Tom's code you can write all the code to a file that you store on your server and then download this file via EG.
[...]
You certainly shouldn't modify them - or then store the modified version under a different name in a site specific SAS Autocall macro library.
Thank you Patrick,
if there is not repository for them ... then Tom's solution is the way to go. I actually was that far ... but I will pick up your suggestion to redirect the output and download that one file ...
Do you mind if I picked Tom's posting as the solution nevertheless? ... it might be a little bit more helpful to users with the same problem and is a pretty reasonable summary of the other postings on autocall macros published here in the community in the past ...
And yes ... using a different name for an altered version of a macro and not "shadowing" the original is a must! Thank you for highlighting that ...
Cheers
fja
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.