@ipym.cell_magic<EOL><INDENT>def SAS(self, line, cell):<DEDENT>
mva = self.mva<EOL>if len(line) and line in self.shell.user_ns:  <EOL><INDENT>_mva = self.shell.user_ns[line]<EOL>if isinstance(_mva, SASsession):<EOL><INDENT>mva = _mva<EOL><DEDENT>else:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT><DEDENT>elif len(line) and not line in self.shell.user_ns:  <EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>else:  <EOL><INDENT>try:<EOL><INDENT>if mva is None:<EOL><INDENT>mva = SASsession()<EOL>self.mva = mva  <EOL><DEDENT>else:<EOL><INDENT>mva = self.mva<EOL><DEDENT><DEDENT>except:<EOL><INDENT>return "<STR_LIT>"<EOL><DEDENT><DEDENT>saveOpts="<STR_LIT>"<EOL>restoreOpts="<STR_LIT>"<EOL>if len(line)><NUM_LIT:0>:  <EOL><INDENT>mva.submit(saveOpts)<EOL><DEDENT>if line.lower()=='<STR_LIT>':<EOL><INDENT>mva.submit("<STR_LIT>")<EOL><DEDENT>elif line is not None and line.startswith('<STR_LIT>'):<EOL><INDENT>mva.submit(line + '<STR_LIT:;>')<EOL><DEDENT>res = mva.submit(cell)<EOL>dis = self._which_display(res['<STR_LIT>'], res['<STR_LIT>'])<EOL>if len(line)><NUM_LIT:0>:  <EOL><INDENT>mva.submit(restoreOpts)<EOL><DEDENT>return dis<EOL>
%%SAS - send the code in the cell to a SAS Server

This cell magic will execute the contents of the cell in a SAS
session and return any generated output

Example:
    %%SAS
    proc print data=sashelp.class;
    run;
    data a;
        set sashelp.cars;
    run;