<?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 How to retain the index after renaming the dataset name? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-retain-the-index-after-renaming-the-dataset-name/m-p/861292#M340227</link>
    <description>&lt;P&gt;I've tried the following program to create a index and I want to check whether index will be retained if we rename the dataset name which has index.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I observed that index is not being retained if we rename the&amp;nbsp;dataset name. Is there a way to retain the&amp;nbsp;index even if we rename the&amp;nbsp;dataset name?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data cars;
set sashelp.cars;
run;

proc contents data=cars noprint
out=index_list(keep=libname memname name);
run;

filename code temp;
data _null_;
set index_list;
by libname memname ;
file code;
if first.libname then put 'proc datasets nolist lib=' libname ';' ;
if first.memname then put 'modify ' memname ';' / '  create index ' @;
put name @;
if last.memname then put ';' / 'run;' ;
if last.libname then put 'quit;' ;
run;

%include code/ source2;

data cars_new;
set cars;
run;

proc contents data=cars_new;
run;

proc contents data=cars;
run;&lt;/PRE&gt;</description>
    <pubDate>Tue, 28 Feb 2023 08:18:30 GMT</pubDate>
    <dc:creator>David_Billa</dc:creator>
    <dc:date>2023-02-28T08:18:30Z</dc:date>
    <item>
      <title>How to retain the index after renaming the dataset name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retain-the-index-after-renaming-the-dataset-name/m-p/861292#M340227</link>
      <description>&lt;P&gt;I've tried the following program to create a index and I want to check whether index will be retained if we rename the dataset name which has index.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I observed that index is not being retained if we rename the&amp;nbsp;dataset name. Is there a way to retain the&amp;nbsp;index even if we rename the&amp;nbsp;dataset name?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data cars;
set sashelp.cars;
run;

proc contents data=cars noprint
out=index_list(keep=libname memname name);
run;

filename code temp;
data _null_;
set index_list;
by libname memname ;
file code;
if first.libname then put 'proc datasets nolist lib=' libname ';' ;
if first.memname then put 'modify ' memname ';' / '  create index ' @;
put name @;
if last.memname then put ';' / 'run;' ;
if last.libname then put 'quit;' ;
run;

%include code/ source2;

data cars_new;
set cars;
run;

proc contents data=cars_new;
run;

proc contents data=cars;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Feb 2023 08:18:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retain-the-index-after-renaming-the-dataset-name/m-p/861292#M340227</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2023-02-28T08:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to retain the index after renaming the dataset name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retain-the-index-after-renaming-the-dataset-name/m-p/861294#M340229</link>
      <description>&lt;P&gt;Your code does not rename a dataset anywhere. All I see is a data step which creates a new dataset (which, of course, will not have an index unless you create one).&lt;/P&gt;
&lt;P&gt;Renaming a dataset is done with the CHANGE statement of PROC DATASETS.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 08:26:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retain-the-index-after-renaming-the-dataset-name/m-p/861294#M340229</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-28T08:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to retain the index after renaming the dataset name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retain-the-index-after-renaming-the-dataset-name/m-p/861297#M340232</link>
      <description>&lt;P&gt;This:&lt;/P&gt;
&lt;PRE&gt;data cars_new;
set cars;
run;&lt;/PRE&gt;
&lt;P&gt;is not renaming. As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;wrote, use proc datasets to rename.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 08:29:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retain-the-index-after-renaming-the-dataset-name/m-p/861297#M340232</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-02-28T08:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to retain the index after renaming the dataset name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retain-the-index-after-renaming-the-dataset-name/m-p/861298#M340233</link>
      <description>&lt;P&gt;There is outage time now due to licence renewal. In the interest of time, I'd like to know whether the index will be retained if we rename the dataset via proc datasets?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 08:31:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retain-the-index-after-renaming-the-dataset-name/m-p/861298#M340233</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2023-02-28T08:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to retain the index after renaming the dataset name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retain-the-index-after-renaming-the-dataset-name/m-p/861302#M340237</link>
      <description>&lt;P&gt;Answer this yourself. Run this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let workpath=%sysfunc(pathname(work));

%put &amp;amp;=workpath.;

data class (index=(sex));
set sashelp.class;
run;

proc datasets lib=work noprint;
change class=class1;
quit;

data dirlist;
length dref $8;
rc = filename(dref,"&amp;amp;workpath.");
did = dopen(dref);
do i = 1 to dnum(did);
  name = dread(did,i);
  put name=;
end;
rc = dclose(did);
rc = filename(dref);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and read the log.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 08:40:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retain-the-index-after-renaming-the-dataset-name/m-p/861302#M340237</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-28T08:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to retain the index after renaming the dataset name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retain-the-index-after-renaming-the-dataset-name/m-p/861307#M340240</link>
      <description>&lt;P&gt;So, index is being retained after renaming the dataset name.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 09:22:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retain-the-index-after-renaming-the-dataset-name/m-p/861307#M340240</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2023-02-28T09:22:00Z</dc:date>
    </item>
  </channel>
</rss>

