<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Programmatically detect an active CAS session? in SAS Viya</title>
    <link>https://communities.sas.com/t5/SAS-Viya/Programmatically-detect-an-active-CAS-session/m-p/890791#M1981</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In SAS Studio, how can I programmatically detect if I have an active CAS session?&lt;/P&gt;
&lt;P&gt;I compared all macro variables and SAS options between the two situation but found nothing that indicates this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
    <pubDate>Thu, 24 Aug 2023 14:50:21 GMT</pubDate>
    <dc:creator>bheinsius</dc:creator>
    <dc:date>2023-08-24T14:50:21Z</dc:date>
    <item>
      <title>Programmatically detect an active CAS session?</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Programmatically-detect-an-active-CAS-session/m-p/890791#M1981</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In SAS Studio, how can I programmatically detect if I have an active CAS session?&lt;/P&gt;
&lt;P&gt;I compared all macro variables and SAS options between the two situation but found nothing that indicates this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2023 14:50:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Programmatically-detect-an-active-CAS-session/m-p/890791#M1981</guid>
      <dc:creator>bheinsius</dc:creator>
      <dc:date>2023-08-24T14:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically detect an active CAS session?</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Programmatically-detect-an-active-CAS-session/m-p/890900#M1982</link>
      <description>&lt;P&gt;I've found when you create a CAS Session it creates two macro variables(&lt;STRONG&gt;_SESSREF_&lt;/STRONG&gt; and &lt;STRONG&gt;_CASNAME_&lt;/STRONG&gt;)&amp;nbsp; with the CAS session name.&lt;/P&gt;
&lt;P&gt;However, if you terminate your CAS session or the CAS session times out, those macro variables still exist. So this might not be the best solution but a start.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run the following code to check if the CAS session conn exists:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cas conn;

/* Check for a specific cas session */
%if &amp;amp;_SESSREF_=CONN %then %do; 
    %put 'Yes the macro variable of a cas session does exist';
%end;
%else %do;
    %put 'No CAS session';
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Does this help?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What's your specific use case for this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2023 19:55:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Programmatically-detect-an-active-CAS-session/m-p/890900#M1982</guid>
      <dc:creator>Panagiotis</dc:creator>
      <dc:date>2023-08-24T19:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically detect an active CAS session?</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Programmatically-detect-an-active-CAS-session/m-p/890905#M1983</link>
      <description>&lt;P&gt;I did some more digging and I think I found the answer. I'll leave my previous post up since the macro variable might be useful to some.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you can use the&amp;nbsp;SESSFOUND Function:&amp;nbsp;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/default/lefunctionsref/p1b4sxnrjxw5y8n1cadgqkdtz8h2.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/default/lefunctionsref/p1b4sxnrjxw5y8n1cadgqkdtz8h2.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put doIExist= %sysfunc(sessfound(add_sesion_name_here));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Returns a 0 when a CAS session is not connected to a server and a 1 when the session is connected to a server.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2023 20:23:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Programmatically-detect-an-active-CAS-session/m-p/890905#M1983</guid>
      <dc:creator>Panagiotis</dc:creator>
      <dc:date>2023-08-24T20:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically detect an active CAS session?</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Programmatically-detect-an-active-CAS-session/m-p/890913#M1984</link>
      <description>That does the trick, thanks!</description>
      <pubDate>Thu, 24 Aug 2023 20:39:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Programmatically-detect-an-active-CAS-session/m-p/890913#M1984</guid>
      <dc:creator>bheinsius</dc:creator>
      <dc:date>2023-08-24T20:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically detect an active CAS session?</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Programmatically-detect-an-active-CAS-session/m-p/890914#M1985</link>
      <description>&lt;P&gt;You're welcome! I just learned about this function. Great question!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Peter&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2023 20:44:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Programmatically-detect-an-active-CAS-session/m-p/890914#M1985</guid>
      <dc:creator>Panagiotis</dc:creator>
      <dc:date>2023-08-24T20:44:04Z</dc:date>
    </item>
  </channel>
</rss>

