<?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: Add index to a CAS table which is already indexed in SAS Viya</title>
    <link>https://communities.sas.com/t5/SAS-Viya/Add-index-to-a-CAS-table-which-is-already-indexed/m-p/963819#M2822</link>
    <description>&lt;P&gt;Moved to &lt;A href="https://communities.sas.com/t5/SAS-Viya/bd-p/about-viya" target="_self"&gt;SAS Viya community&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 09 Apr 2025 06:44:26 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2025-04-09T06:44:26Z</dc:date>
    <item>
      <title>Add index to a CAS table which is already indexed</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Add-index-to-a-CAS-table-which-is-already-indexed/m-p/963665#M2821</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The tests have been done on VIYA LTS 2023.03 and VIYA LTS 2024.09&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried to add a new index to a promoted table which has already other indexes (the reason why a new index has&amp;nbsp; to be added at a later moment rather than from the beginning is because new requirements and also the table is quite large and I try to avoid delete it and recreate it)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the tests&amp;nbsp; I have used the table sashelp.cars which has been added to casuser and promoted. The first index has been added to variable "make" and a new table has been created and promoted.&amp;nbsp;table.columnInfo has been used to check if the index has been applied&amp;nbsp; (please see code below).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc cas; &lt;BR /&gt;table.index /&lt;BR /&gt;table={caslib='casuser',name="cars"},&lt;BR /&gt;casOut={name="cars_idx2", caslib='casuser',indexVars={"make"},promote=True};&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;table.columnInfo /table={name="cars_idx2",caslib="casuser"};&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Later I have tried to add a new index to variable "type" to the promoted table casuser.cars_idx2. (the code is below)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc cas;                                                          &lt;BR /&gt;   table.index /&lt;BR /&gt;      table={caslib='casuser',name="cars_idx2"},&lt;BR /&gt;      casOut={name="cars_idx2", caslib='casuser',&lt;BR /&gt;              indexVars={"type"} ,replace=True};&lt;BR /&gt;  table.columnInfo /   table={name="cars_idx2",  caslib="casuser"};&lt;BR /&gt;  table.tableInfo / caslib="casuser", name="cars_idx2";&lt;BR /&gt;quit;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="smm662002_0-1744104128830.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105995i76F2EECA6A8F8F88/image-size/medium?v=v2&amp;amp;px=400" role="button" title="smm662002_0-1744104128830.png" alt="smm662002_0-1744104128830.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt; &lt;/PRE&gt;
&lt;P&gt;From table.columnInfo we can see that the index has been applied, but, looking at table.tableInfo results we can see that the scope of table cars_idx2 is no longer global but session scope.&amp;nbsp;&lt;BR /&gt;The output of table.columnInfo and table.tableInfo is abovew. A similar behavior was presented in the article &lt;A href="http://proc-x.com/2020/12/append-and-replace-records-in-a-cas-table/" target="_blank"&gt;http://proc-x.com/2020/12/append-and-replace-records-in-a-cas-table/&amp;nbsp;&lt;/A&gt;where manipulating promoted cas table with data steps can leads to duplication of data. &lt;BR /&gt;&lt;BR /&gt;But in this scenario it seems that even a cas action can lead to duplicated data having local and global scope. I hoped that using "replace=True" would help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can I apply a new index to an existing promoted indexed table without having to delete and recreate that table?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your comments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;smm662002&lt;/P&gt;</description>
      <pubDate>Tue, 08 Apr 2025 09:31:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Add-index-to-a-CAS-table-which-is-already-indexed/m-p/963665#M2821</guid>
      <dc:creator>smm662002</dc:creator>
      <dc:date>2025-04-08T09:31:27Z</dc:date>
    </item>
    <item>
      <title>Re: Add index to a CAS table which is already indexed</title>
      <link>https://communities.sas.com/t5/SAS-Viya/Add-index-to-a-CAS-table-which-is-already-indexed/m-p/963819#M2822</link>
      <description>&lt;P&gt;Moved to &lt;A href="https://communities.sas.com/t5/SAS-Viya/bd-p/about-viya" target="_self"&gt;SAS Viya community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Apr 2025 06:44:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Viya/Add-index-to-a-CAS-table-which-is-already-indexed/m-p/963819#M2822</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2025-04-09T06:44:26Z</dc:date>
    </item>
  </channel>
</rss>

