user2146441
user2146441

Reputation: 228

SAS Latex Destination: Suppress SAS escape chars

When I run the following and output to the ODS Latex desination, SAS escapes the dollar sign and all the brackets, which won't compile in Latex.

How can I output what's in each cell verbatim?

ods escapechar='^';

Proc format;
picture sigstar (round)
    low-0.01="***" (NOEDIT)
    0.01<-0.05="** " (FILL=' ' PREFIX='')
    0.05<-0.10="*  " (FILL=' ' PREFIX='')
    other=     " " (FILL=' ' PREFIX='');
run;

data test;
   input mean pvalue;
   datalines; 
   2.50 0.001
   3.50 0.05
   4.25 0.12
   5.00 0.01
   ;
run;

data test;
   set test;
   output = cats( put(mean,7.2)  , '{$^{', put(pvalue,sigstar.),'}$}' );
   format pvalue sigstar.;
   drop mean pvalue;
run;

ods tagsets.simplelatex file="test.tex" (notop nobot);
   proc print data=test;run;
ods tagsets.simplelatex close;

This outputs the following .text code:

\sassystemtitle[c]{~}
\sascontents[1]{The Print Procedure}
\sascontents[2]{Data Set WORK.TEST}


\begin{longtable}{|r|l|r|}\hline
   Obs &    output &    pvalue\\\hline
\endhead
   1 &    2.50\{\$\^\{***\}\$\} &    ~\\\hline
   2 &    3.50\{\$\^\{**\}\$\} &    ~\\\hline
   3 &    4.25\{\$\^\{\}\$\} &    ~\\\hline
   4 &    5.00\{\$\^\{***\}\$\} &    ~\\\hline
\end{longtable}

How can I ensure that the second cell in the first row shows 2.50{$^{***}$} and not 2.50\{\$\^\{***\}\$\}? The package I'm using in Latex requires that the stars are surrounded by the chars above, so I just want to output what's in the dataset verbatim.

Upvotes: 1

Views: 149

Answers (2)

user2146441
user2146441

Reputation: 228

To avoid these characters being escaped it suffices to edit the following lines at the end of the SimpleLatex tagset:

mapsub = %nrstr("/\%%/$/\&/\~/\\#/{\textunderscore}");
map = %nrstr("%%$&~#_");

Upvotes: 1

Joe
Joe

Reputation: 63424

I don't think you would generally do that in latex tagsets. The point of tagsets is to take normal SAS data and reformat it to make a latex file; what you're doing is manually doing the latex file itself.

This paper shows an example of how you can do something close to what you want; basically, you write the latex file sans-SAS provided graphs or charts, mark where you want the SAS part to go, and effectively paste it in via SAS code. You should also be able to do the writing of the initial latex file in SAS - but don't do it with the tagset, just write it directly in a data step put.

The easiest way, though, may be to simply customize your own latex tagset. Edit the one closest to what you are looking for, and add in your own code as needed. An example is this question.

Upvotes: 1

Related Questions