5

I would like to show some SAS code like in SAS Enterprise Guide:

enter image description here

The following is what I've got so far, but only the "string" is more or less like what I want.

Please take into account that I need this at work (eventually, I've found an occasion to use LaTeX at work, yay!), hence I can't install anything on my computer, I can use only Overleaf, ShareLaTeX or Verbosus.

enter image description here

\documentclass[a4paper,12pt, twoside]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage[top=1.5in,bottom=1in,right=1in,left=1.3in,headheight=65pt,headsep=1cm]{geometry}
\usepackage{xcolor}

\usepackage{listings}
\lstset{language=SAS, 
  breaklines=true,  
  basicstyle=\ttfamily\bfseries,
  columns=fixed,
  keepspaces=true,
  identifierstyle=\color{blue}\ttfamily,
  keywordstyle=\color{cyan}\ttfamily,
  stringstyle=\color{purple}\ttfamily,
  commentstyle=\color{green}\ttfamily,
  } 

\begin{document} 

\begin{lstlisting}
/* librerie */
libname mylib '/mydir/mysubdir';

/* ordinamento */
proc sort data=mylib.myfile out=myfilesorted nodupkey;
by mykey;
run;

* data myfile2; /* istruzione commentata */
data myfilejoinsanother;
merge myfilesorted (in=my)
      anotherfile (in=theother rename=(myfield=mykey));
by mykey;
if my;
run;
\end{lstlisting}
\end{document}
0

1 Answer 1

4

A partial solution: You could use minted. It has a sas lexer and you can use a style like borland or vs that nearly resembles your need.

borland style

% arara: pdflatex: { shell: yes }
\documentclass[a4paper,12pt, twoside]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage[top=1.5in,bottom=1in,right=1in,left=1.3in,headheight=65pt,headsep=1cm]{geometry}
\usepackage{xcolor}

\usepackage{listings}
\usepackage{minted}
\usemintedstyle{borland}
\lstset{language=SAS, 
  breaklines=true,  
  basicstyle=\ttfamily\bfseries,
  columns=fixed,
  keepspaces=true,
  identifierstyle=\color{blue}\ttfamily,
  keywordstyle=\color{cyan}\ttfamily,
  stringstyle=\color{purple}\ttfamily,
  commentstyle=\color{green}\ttfamily,
  } 

\begin{document} 

\begin{minted}{sas}
/* librerie */
libname mylib '/mydir/mysubdir';

/* ordinamento */
proc sort data=mylib.myfile out=myfilesorted nodupkey;
by mykey;
run;

* data myfile2; /* istruzione commentata */
data myfilejoinsanother;
merge myfilesorted (in=my)
      anotherfile (in=theother rename=(myfield=mykey));
by mykey;
if my;
run;
\end{minted}
\end{document}
2
  • I can only guess that Overleaf, ShareLaTeX etc. support this (at least they have tutorials for it).
    – TeXnician
    Commented Jul 18, 2017 at 15:26
  • This is enough for me, it doesn't work with Overleaf but it works with ShareLaTeX. I'll wait a bit before accepting it but it's OK.
    – CarLaTeX
    Commented Jul 18, 2017 at 15:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .