BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
sskt
Obsidian | Level 7

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?

https://communities.sas.com/t5/SAS-Programming/Is-there-any-way-to-store-the-source-code-of-SAS-Util...

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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.

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

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.

ballardw
Super User

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.

Patrick
Opal | Level 21

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.

s_lassen
Meteorite | Level 14

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.

 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 563 views
  • 4 likes
  • 5 in conversation