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.
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.
I prefer this macro for adding single quotes.
%macro squote(value);
%unquote(%str(%')%qsysfunc(tranwrd(%superq(value),%str(%'),''))%str(%'))
%mend squote;
Try both with an empty string.
Try both with SYMBOLGEN turned on and see which one causes your log to fill up.
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.
https://github.com/scottbass/SAS/blob/master/Macro/squote.sas
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.
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!
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.