We’re smarter together. Learn from this collection of community knowledge and add your expertise.

Not All Macro Language Elements Are Supported by the Macro Facility

by SAS Employee Sue_SAS on ‎05-28-2015 03:12 PM - edited on ‎10-05-2015 03:13 PM by Community Manager (1,032 Views)

If a macro language element is created for a specific product, it will not be documented in the SAS Macro Language Reference or supported by the SAS Macro Facility. Lately, the %TSLIT macro function has been discussed in the SAS Communities because the documentation refers the customer to the SAS Macro Language Reference. The %TSLIT macro function was created for the DS2 and FEDSQL procedures. Beginning in SAS 9.4m3, documentation for %TSLIT will be located in the SAS 9.4 FedSQL Language Reference, and SAS 9.4 DS2 Language Reference.

by Trusted Advisor
on ‎05-29-2015 04:27 PM

Kind of a misleading title on this...

I was thinking the name suggests %TSLIT was developed for PROC TSSQL, it's also the procedure mentioned in the documentation internal to the macro itself.  It's a useful little utility for surrounding a given string with properly single quotes, even when the input contains embedded full or partial quotes itself.

by Super User
on ‎05-29-2015 04:53 PM

I prefer this macro for adding single quotes. 

%macro squote(value);


%mend squote;

Try both with an empty string.

Try both with SYMBOLGEN turned on and see which one causes your log to fill up.

by Trusted Advisor
on ‎05-29-2015 04:59 PM

, Nicely done.  As usual.

by Super Contributor
on ‎10-28-2016 12:58 AM

1) Why the macro name %tslit?  T-slit???  TS-lit?  Does the name make it clear the macro's functionality?  Is it easy to remember?


2) Beyond the strange name, can't SAS just make this code the %tslit macro?  It seems better than the OOTB version.


3) In case someone finds this post in the future...I did a bunch of testing with unbalanced single quotes.  These are the only use cases I could get to work:



* this works because the parameter is macro quoted, ;
* and the %squote macro returns balanced quotation marks ;
* so the %put statement works ;
%let mvar=%bquote(P.J. O'Briens);   %put %squote(&mvar);
* this works ;
%let mvar=%bquote(P.J. O'Briens);
%let newmvar = %squote(&mvar);
%put &=newmvar;  

I've stolen this macro and added it to my kitbag.  Tom, I've tried to give you full attribution.  If you prefer I give your full name, email address, and home address, just let me know ;).  Seriously, let me know if you want me to pull it down from GitHub.  Thanks for the useful macro.



by Community Manager
on ‎10-28-2016 08:30 AM

Hi @ScottBass, TSLIT comes from "Table Server literal" -- Table Server Programming Language (PROC TSPL) was an early name for what we now call PROC DS2.  And the %tslit macro is an approach to compensate for the way that databases usually require single quotes for literals (unlike SAS, which is happy with single or double quotes), and sometimes the values you're using are messy with odd quotes or apostrophes in the mix.


So is it easy to remember?  Sure, if you're a SAS historian.  Otherwise it's just like another function whose name doesn't really tell the whole story, but still it does exactly what you need.

Your turn
Sign In!

Want to write an article? Sign in with your profile.