<?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 Re: Recognize the current active CAS session in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Recognize-the-current-active-CAS-session/m-p/786928#M251321</link>
    <description>&lt;P&gt;According to a note from log:&lt;/P&gt;
&lt;PRE&gt;Use the OPTIONS statement to set the SESSREF= option to an active session.&lt;/PRE&gt;
&lt;P&gt;Maybe the option should be set first (before point 7)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Dec 2021 13:49:50 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2021-12-21T13:49:50Z</dc:date>
    <item>
      <title>Recognize the current active CAS session</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recognize-the-current-active-CAS-session/m-p/786914#M251313</link>
      <description>&lt;P&gt;The contex: I would like to know, what is the current active(default) session.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please, check the piece of code and explain how steps 7-9 work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*1. Create 3 cas sessions  */
cas s1;
cas s2;
cas s3;

/*2. List the sessions - we can see 3 sessions. Looks OK  */
cas _ALL_ list ;

/*3. Use _CASNAME_ to check the active session. Looks OK */
%put We expect S3 &amp;amp;=_CASNAME_;

/*4. Assign caslib. Created for S3. Looks OK  */
libname casuser cas caslib=casuser;

/*5. Terminate session S3  */
cas s3 terminate;

/*6. List the sessions - we can see 2 sessions. Looks OK  */
cas _ALL_ list ;

/*7. CASNAME is still S3, but I expect to see S2.  */
%put We expect S2 &amp;amp;=_CASNAME_;

/*8. Libname creates new cas session S3. I expect to see connection S2  */
libname casuser cas caslib=casuser;

/*9. After the libname we again see 3 cas session. S3 was automatically created  */
cas _ALL_ list ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The log I have:&lt;/P&gt;
&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;PRE&gt;82   /*1. Create 3 cas sessions  */
83   cas s1;
NOTE: The session S1 connected successfully to Cloud Analytic Services dvmictsas001.health.fgov.be using port 5570. The UUID is 
      204a4f74-9c47-6541-a0e8-9c6ff6fb8f45. The user is dki and the active caslib is CASUSER(dki).
NOTE: The SAS option SESSREF was updated with the value S1.
NOTE: The SAS macro _SESSREF_ was updated with the value S1.
NOTE: The session is using 0 workers.
84   cas s2;
NOTE: The session S2 connected successfully to Cloud Analytic Services dvmictsas001.health.fgov.be using port 5570. The UUID is 
      13db7c51-6693-7c4b-8746-a9b2b45047f5. The user is dki and the active caslib is CASUSER(dki).
NOTE: The SAS option SESSREF was updated with the value S2.
NOTE: The SAS macro _SESSREF_ was updated with the value S2.
NOTE: The session is using 0 workers.
85   cas s3;
NOTE: The session S3 connected successfully to Cloud Analytic Services dvmictsas001.health.fgov.be using port 5570. The UUID is 
      8bba1ab2-6287-ee41-a8e0-05fdb1419acb. The user is dki and the active caslib is CASUSER(dki).
NOTE: The SAS option SESSREF was updated with the value S3.
NOTE: The SAS macro _SESSREF_ was updated with the value S3.
NOTE: The session is using 0 workers.
86   
87   /*2. List the sessions - we can see 3 sessions. Looks OK  */
88   cas _ALL_ list ;
NOTE: Session S1 is ACTIVE using port 5570 and host dvmictsas001.health.fgov.be for user dki. The session UUID is 
      204a4f74-9c47-6541-a0e8-9c6ff6fb8f45.
NOTE: Session S2 is ACTIVE using port 5570 and host dvmictsas001.health.fgov.be for user dki. The session UUID is 
      13db7c51-6693-7c4b-8746-a9b2b45047f5.
NOTE: Session S3 is ACTIVE using port 5570 and host dvmictsas001.health.fgov.be for user dki. The session UUID is 
      8bba1ab2-6287-ee41-a8e0-05fdb1419acb.
89   
90   /*3. Use _CASNAME_ to check the active session. Looks OK */
91   %put We expect S3 &amp;amp;=_CASNAME_;
We expect S3 _CASNAME_=S3
92   
93   /*4. Assign caslib. Created for S3. Looks OK  */
94   libname casuser cas caslib=casuser;
NOTE: Libref CASUSER was successfully assigned as follows: 
      Engine:        CAS 
      Physical Name: 8bba1ab2-6287-ee41-a8e0-05fdb1419acb
95   
96   /*5. Terminate session S3  */
97   cas s3 terminate;
NOTE: Libref CASUSER has been deassigned.
NOTE: Deletion of the session S3 was successful.
NOTE: The default CAS session S3 identified by SAS option SESSREF= was terminated. Use the OPTIONS statement to set the SESSREF= 
      option to an active session.
NOTE: Request to TERMINATE completed for session S3.
98   
99   /*6. List the sessions - we can see 2 sessions. Looks OK  */
100  cas _ALL_ list ;
NOTE: Session S1 is ACTIVE using port 5570 and host dvmictsas001.health.fgov.be for user dki. The session UUID is 
      204a4f74-9c47-6541-a0e8-9c6ff6fb8f45.
NOTE: Session S2 is ACTIVE using port 5570 and host dvmictsas001.health.fgov.be for user dki. The session UUID is 
      13db7c51-6693-7c4b-8746-a9b2b45047f5.
101  
102  /*7. CASNAME is still S3, but I expect to see S2.  */
103  %put We expect S2 &amp;amp;=_CASNAME_;
We expect S2 _CASNAME_=S3
104  
105  /*8. Libname creates new cas session S3. I expect to see connection S2  */
106  libname casuser cas caslib=casuser;
NOTE: The session S3 connected successfully to Cloud Analytic Services dvmictsas001.health.fgov.be using port 5570. The UUID is 
      26cf8715-f5a8-ab4c-8792-d9873df8879a. The user is dki and the active caslib is CASUSER(dki).
NOTE: The SAS option SESSREF was updated with the value S3.
NOTE: The SAS macro _SESSREF_ was updated with the value S3.
NOTE: The session is using 0 workers.
NOTE: Libref CASUSER was successfully assigned as follows: 
      Engine:        CAS 
      Physical Name: 26cf8715-f5a8-ab4c-8792-d9873df8879a
107  
108  /*9. After the libname we again see 3 cas session. S3 was automatically created  */
109  cas _ALL_ list ;
NOTE: Session S1 is ACTIVE using port 5570 and host dvmictsas001.health.fgov.be for user dki. The session UUID is 
      204a4f74-9c47-6541-a0e8-9c6ff6fb8f45.
NOTE: Session S2 is ACTIVE using port 5570 and host dvmictsas001.health.fgov.be for user dki. The session UUID is 
      13db7c51-6693-7c4b-8746-a9b2b45047f5.
NOTE: Session S3 is ACTIVE using port 5570 and host dvmictsas001.health.fgov.be for user dki. The session UUID is 
      26cf8715-f5a8-ab4c-8792-d9873df8879a.&lt;/PRE&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 10:58:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recognize-the-current-active-CAS-session/m-p/786914#M251313</guid>
      <dc:creator>idziemianczyk</dc:creator>
      <dc:date>2021-12-21T10:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: Recognize the current active CAS session</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recognize-the-current-active-CAS-session/m-p/786928#M251321</link>
      <description>&lt;P&gt;According to a note from log:&lt;/P&gt;
&lt;PRE&gt;Use the OPTIONS statement to set the SESSREF= option to an active session.&lt;/PRE&gt;
&lt;P&gt;Maybe the option should be set first (before point 7)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 13:49:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recognize-the-current-active-CAS-session/m-p/786928#M251321</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2021-12-21T13:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: Recognize the current active CAS session</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recognize-the-current-active-CAS-session/m-p/786929#M251322</link>
      <description>&lt;P&gt;Hi Bart, thanks for the response. For sure it will work if I set SESSREF.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With SESSREF= option we can assign CAS action for any of the opened sessions, there are no doubts about it.&lt;/P&gt;
&lt;P&gt;The tricky part we don't know which session is chosen automatically when we haven't set the SESSREF explicitly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to understand the logic of assigning the default SESSREF.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 14:00:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recognize-the-current-active-CAS-session/m-p/786929#M251322</guid>
      <dc:creator>idziemianczyk</dc:creator>
      <dc:date>2021-12-21T14:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: Recognize the current active CAS session</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recognize-the-current-active-CAS-session/m-p/786934#M251325</link>
      <description>&lt;P&gt;From the doc of&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/v_021/casref/n0z3r80fjqpobvn1lvegno9gefni.htm" target="_blank"&gt;SAS Help Center: CAS Statement&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4 class="xisDoc-argument"&gt;TERMINATE&lt;/H4&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;P&gt;&lt;SPAN class="xisDoc-shortDescription"&gt;terminates a single connected or disconnected session, or all of the connected and disconnected sessions in your SAS client.&lt;/SPAN&gt;&lt;/P&gt;
&lt;SECTION class="xisDoc-tableWrap"&gt;
&lt;TABLE class="xisDoc-summary"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="xisDoc-alias"&gt;Alias&lt;/TH&gt;
&lt;TD class="xisDoc-summaryText"&gt;CLEAR&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="xisDoc-summaryNote" rowspan="2"&gt;Notes&lt;/TH&gt;
&lt;TD class="xisDoc-summaryText"&gt;&lt;STRONG&gt;When you terminate the active session, SAS system option SESSREF= continues to reference the terminated session. A note is written to the SAS log indicating that the session identified by SAS system option SESSREF= was terminated.&lt;/STRONG&gt; To access the server in that case, you must start a new session or set system option SESSREF= to an existing connected session. See&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A tabindex="0" href="https://documentation.sas.com/doc/en/pgmsascdc/v_021/casref/n0z3r80fjqpobvn1lvegno9gefni.htm#p1fzayvgmpow0mn1ivop3pqakrx5" target="_blank"&gt;Start a Session&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A tabindex="0" href="https://documentation.sas.com/doc/en/pgmsascdc/v_021/lesysoptsref/p1ubn5s5ylmecin16deas1jtytln.htm" target="_blank"&gt;SESSREF= System Option&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="xisDoc-xrefBookTitle"&gt;SAS System Options: Reference&lt;/SPAN&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="xisDoc-summaryText"&gt;If you terminate a session that you disconnected using DISCONNECT, the disconnected session is removed from your client's session list, but it continues to run on the server until its time-out expires. To terminate the session in that case, see&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A tabindex="0" href="https://documentation.sas.com/doc/en/pgmsascdc/v_021/casref/n0z3r80fjqpobvn1lvegno9gefni.htm#p1fyi68ca3sfwqn1xoq0r7urffh8" target="_blank"&gt;Terminating a Disconnected Session&lt;/A&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="xisDoc-summaryTip"&gt;Tip&lt;/TH&gt;
&lt;TD class="xisDoc-summaryText"&gt;Use this option with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;session-name&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to terminate a single connected or disconnected session, or use it with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A tabindex="0" href="https://documentation.sas.com/doc/en/pgmsascdc/v_021/casref/n0z3r80fjqpobvn1lvegno9gefni.htm#n0v4ep0p0lp8ksn1g10f1tah59ui" target="_blank"&gt;_ALL_&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to terminate all of the currently connected and disconnected sessions in your SAS client.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="xisDoc-summarySee"&gt;See&lt;/TH&gt;
&lt;TD class="xisDoc-summaryText"&gt;&lt;A tabindex="0" href="https://documentation.sas.com/doc/en/pgmsascdc/v_021/casref/n0z3r80fjqpobvn1lvegno9gefni.htm#p1irjj67vusybon1wwjk8jtxmcjp" target="_blank"&gt;Terminate a Session&lt;/A&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like it updates the value with every "cas" statement execution, but do not updates it after terminating.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;82     /*1. Create 3 cas sessions  */
83     %put &amp;amp;=_CASNAME_;
WARNING: Apparent symbolic reference _CASNAME_ not resolved.
_CASNAME_
84     cas s1;
NOTE: The session S1 connected successfully to Cloud Analytic Services yyyyyyyyyyy.exnet.sas.com using port 5571. The UUID is 
      9bf41b83-b09a-f14e-811f-c4135b70ed9f. The user is xxxxxxxxxxxxxxxxxxxxxx and the active caslib is 
      CASUSER(xxxxxxxxxxxxxxxxxxxxxx).
NOTE: The SAS option SESSREF was updated with the value S1.
NOTE: The SAS macro _SESSREF_ was updated with the value S1.
NOTE: The session is using 0 workers.
85     %put &amp;amp;=_CASNAME_;
_CASNAME_=S1
86     cas s2;
NOTE: The session S2 connected successfully to Cloud Analytic Services yyyyyyyyyyy.exnet.sas.com using port 5571. The UUID is 
      77b6afaf-fc52-5d41-a6ab-1e962a2df8d4. The user is xxxxxxxxxxxxxxxxxxxxxx and the active caslib is 
      CASUSER(xxxxxxxxxxxxxxxxxxxxxx).
NOTE: The SAS option SESSREF was updated with the value S2.
NOTE: The SAS macro _SESSREF_ was updated with the value S2.
NOTE: The session is using 0 workers.
87     %put &amp;amp;=_CASNAME_;
_CASNAME_=S2
88     cas s3;
NOTE: The session S3 connected successfully to Cloud Analytic Services yyyyyyyyyyy.exnet.sas.com using port 5571. The UUID is 
      9e3c1ab8-2a5f-014c-8ece-edd77f22ab0e. The user is xxxxxxxxxxxxxxxxxxxxxx and the active caslib is 
      CASUSER(xxxxxxxxxxxxxxxxxxxxxx).
NOTE: The SAS option SESSREF was updated with the value S3.
NOTE: The SAS macro _SESSREF_ was updated with the value S3.
NOTE: The session is using 0 workers.
89     %put &amp;amp;=_CASNAME_;
_CASNAME_=S3
90     
91     /*2. List the sessions - we can see 3 sessions. Looks OK  */
92     cas _ALL_ list ;
NOTE: Session S1 is ACTIVE using port 5571 and host yyyyyyyyyyy.exnet.sas.com for user xxxxxxxxxxxxxxxxxxxxxx. The session UUID 
      is 9bf41b83-b09a-f14e-811f-c4135b70ed9f.
NOTE: Session S2 is ACTIVE using port 5571 and host yyyyyyyyyyy.exnet.sas.com for user xxxxxxxxxxxxxxxxxxxxxx. The session UUID 
      is 77b6afaf-fc52-5d41-a6ab-1e962a2df8d4.
NOTE: Session S3 is ACTIVE using port 5571 and host yyyyyyyyyyy.exnet.sas.com for user xxxxxxxxxxxxxxxxxxxxxx. The session UUID 
      is 9e3c1ab8-2a5f-014c-8ece-edd77f22ab0e.&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;/SECTION&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 21 Dec 2021 14:28:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recognize-the-current-active-CAS-session/m-p/786934#M251325</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2021-12-21T14:28:22Z</dc:date>
    </item>
  </channel>
</rss>

