Hello!
Are there any other default macros provided by SAS besides the %DS2CSV macro? If there are high quality macros made by SAS, I would like to use them.
The following page shows that I can get the macro program, but where is the directory where it is stored?
You should be able to find the source code for SAS supplied autocall macros (and any other autocall macros in your current environment) by checking the SASAUTOS setting and looking that directories that are included.
Finding other macros that SAS provides sometimes can be harder. There are macros the Enterprise Guide or SAS/Studio might pre-compile as part of the startup process for your SAS session that might not be available in SASAUTOS.
Most SAS supplied macro are functional. Quality is in the eye of beholder.
You should be able to find the source code for SAS supplied autocall macros (and any other autocall macros in your current environment) by checking the SASAUTOS setting and looking that directories that are included.
Finding other macros that SAS provides sometimes can be harder. There are macros the Enterprise Guide or SAS/Studio might pre-compile as part of the startup process for your SAS session that might not be available in SASAUTOS.
Most SAS supplied macro are functional. Quality is in the eye of beholder.
If you run this code:
data example; root = sysget('sasroot'); value=sysget('sasautos'); run;
The data set will contain the main path to the SAS stuff in the Root variable and the subfolders with autocall macro library members. You can look in those folders for actual macro code program files.
I'm not aware of a single place in the SAS documentation where all these OOTB macros would be listed or if all of them are documented at all.
Below documentation I could find.
https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/allprodsle/syntaxByProduct-macro.htm
https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n0y4dqfh8w2bpvn19uynlcai3mom.htm
https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/allprodslang/syntaxByProduct-macroARM.htm
For OOTB macros where you can't find SAS documentation:
Even though they exist and likely will continue to exist in future SAS versions I'd ask myself for a production worthy implementation if I would want to rely on anything undocumented (=potentially unsupported).
Others already explained how the find the locations where the macros are stored.
There are some, as listed in the documentation links by @Patrick.
But a lot of them are very old and should have been rewritten a long time ago.
For instance the %VERIFY macro, which emulates the VERIFY data step function, using a macro loop. It works, but if you have any concerns about the execution speed, you should use e.g. %sysfunc(verify(&x,&a)) instead of %verify(&x,&a). Also, if you are debugging a macro call with SYMBOLGEN, a single call to %verify can generate many lines of irrelevant output.
The same goes for some of the others. My advice is that if a macro is supposed to emulate a datastep function, you are probably better off calling the datastep function using %SYSFUNC or %QSYSFUNC. Same for the %TSLIT macro, which probably was written before the QUOTE function got a second parameter - so what it does is equivalent to using the QUOTE function with a single quote as the second parameter:
69 options symbolgen; 70 %let a=test; 71 %put %tslit(&a); SYMBOLGEN: Macro variable A resolves to test SYMBOLGEN: Macro variable VALUE resolves to test SYMBOLGEN: Macro variable VALUE resolves to test SYMBOLGEN: Macro variable S1 resolves to '" SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing. SYMBOLGEN: Macro variable S2 resolves to "' SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing. SYMBOLGEN: Macro variable V1 resolves to test SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing. SYMBOLGEN: Macro variable V2 resolves to "test" SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing. SYMBOLGEN: Macro variable S2 resolves to "' SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing. SYMBOLGEN: Macro variable S1 resolves to '" SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing. SYMBOLGEN: Macro variable V3 resolves to 'test' SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing. 'test' 72 %put %sysfunc(quote(&a,%str(%'))); SYMBOLGEN: Macro variable A resolves to test 'test'
The TSLIT call is shorter code, but it is also slower, and it adds another unnecessary layer of complexity to the program.
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.