<?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: Rename all dataset names in a library by dropping the  common suffix in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-dataset-names-in-a-library-by-dropping-the-common/m-p/837962#M331340</link>
    <description>&lt;P&gt;If this was all in WORK, this is how I would do it. Note this works for a smaller amount of data sets (a few hundred). If the macro variable gets too big then a data step/call execute approach is appropriate instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*delete fake data to avoid issues;
proc datasets nodetails nolist;
delete first second third fourth_multi fifth_drthtest;
quit;

*create fake data for testing;
data first_drt;
set sashelp.class;
data second_drt;
set sashelp.class;
data third_drt;
set sashelp.class;
run;
data fourth_multi_drt;
set sashelp.class;
run;
data fifth_drthtest_drt;
set sashelp.class;
run;


*create a macro variable with the new and old names;
proc sql NOPRINT;
select catx("=", /*separator between name and new name*/
            memname,  /*original name*/
            substr(memname, 1, length(memname)-4) /*new name, 4 is length of suffix to remove*/
            ) into :rename_list separated by " "
from sashelp.vtable 
where libname='WORK' and memname like '%_DRT';
quit;

*display macro variable for confirmation;
%put &amp;amp;rename_list.;

options symbolgen;
proc datasets lib=work nodetails nolist;
change &amp;amp;rename_list;
quit;
options nosymbolgen;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt;1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 SYMBOLGEN:  Macro variable _SASWSTEMP_ resolves to /home/fkhurshed/.sasstudio/.images/d3a117db-e70b-4b05-aa58-1ef8b16a1397
 SYMBOLGEN:  Some characters in the above value which were subject to macro quoting have been unquoted for printing.
 SYMBOLGEN:  Macro variable GRAPHINIT resolves to GOPTIONS RESET=ALL GSFNAME=_GSFNAME;
 68         
 69         *delete fake data to avoid issues;
 70         proc datasets nodetails nolist;
 71         delete first second third fourth_multi fifth_drthtest;
 72         quit;
 
 NOTE: Deleting WORK.FIRST (memtype=DATA).
 NOTE: Deleting WORK.SECOND (memtype=DATA).
 NOTE: Deleting WORK.THIRD (memtype=DATA).
 NOTE: Deleting WORK.FOURTH_MULTI (memtype=DATA).
 NOTE: Deleting WORK.FIFTH_DRTHTEST (memtype=DATA).
 NOTE: PROCEDURE DATASETS used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              362.18k
       OS Memory           25252.00k
       Timestamp           10/11/2022 11:42:16 PM
       Step Count                        156  Switch Count  10
       Page Faults                       0
       Page Reclaims                     57
       Page Swaps                        0
       Voluntary Context Switches        45
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
       
 
 73         
 74         *create fake data for testing;
 75         data first_drt;
 76         set sashelp.class;
 
 NOTE: There were 19 observations read from the data set SASHELP.CLASS.
 NOTE: The data set WORK.FIRST_DRT has 19 observations and 5 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              685.21k
       OS Memory           25508.00k
       Timestamp           10/11/2022 11:42:16 PM
       Step Count                        157  Switch Count  2
       Page Faults                       0
       Page Reclaims                     124
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 77         data second_drt;
 
 78         set sashelp.class;
 
 NOTE: There were 19 observations read from the data set SASHELP.CLASS.
 NOTE: The data set WORK.SECOND_DRT has 19 observations and 5 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              684.84k
       OS Memory           25508.00k
       Timestamp           10/11/2022 11:42:16 PM
       Step Count                        158  Switch Count  2
       Page Faults                       0
       Page Reclaims                     90
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 79         data third_drt;
 
 80         set sashelp.class;
 81         run;
 
 NOTE: There were 19 observations read from the data set SASHELP.CLASS.
 NOTE: The data set WORK.THIRD_DRT has 19 observations and 5 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.01 seconds
       system cpu time     0.00 seconds
       memory              685.21k
       OS Memory           25508.00k
       Timestamp           10/11/2022 11:42:16 PM
       Step Count                        159  Switch Count  2
       Page Faults                       0
       Page Reclaims                     88
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 82         data fourth_multi_drt;
 83         set sashelp.class;
 84         run;
 
 NOTE: There were 19 observations read from the data set SASHELP.CLASS.
 NOTE: The data set WORK.FOURTH_MULTI_DRT has 19 observations and 5 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              685.21k
       OS Memory           25508.00k
       Timestamp           10/11/2022 11:42:16 PM
       Step Count                        160  Switch Count  2
       Page Faults                       0
       Page Reclaims                     88
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 85         data fifth_drthtest_drt;
 86         set sashelp.class;
 87         run;
 
 NOTE: There were 19 observations read from the data set SASHELP.CLASS.
 NOTE: The data set WORK.FIFTH_DRTHTEST_DRT has 19 observations and 5 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              684.84k
       OS Memory           25508.00k
       Timestamp           10/11/2022 11:42:16 PM
       Step Count                        161  Switch Count  2
       Page Faults                       0
       Page Reclaims                     88
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 88         
 89         
 90         *create a macro variable with the new and old names;
 91         proc sql NOPRINT;
 92         select catx("=", /*separator between name and new name*/
 93                     memname,  /*original name*/
 94                     substr(memname, 1, length(memname)-4) /*new name, 4 is length of suffix to remove*/
 95                     ) into :rename_list separated by " "
 96         from sashelp.vtable
 97         where libname='WORK' and memname like '%_DRT';
 98         quit;
 NOTE: PROCEDURE SQL used (Total process time):
       real time           0.00 seconds
       user cpu time       0.01 seconds
       system cpu time     0.01 seconds
       memory              5266.28k
       OS Memory           30372.00k
       Timestamp           10/11/2022 11:42:16 PM
       Step Count                        162  Switch Count  0
       Page Faults                       0
       Page Reclaims                     44
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           0
       
 
 99         
 100        *display macro variable for confirmation;
 101        %put &amp;amp;rename_list.;
 SYMBOLGEN:  Macro variable RENAME_LIST resolves to FIFTH_DRTHTEST_DRT=FIFTH_DRTHTEST FIRST_DRT=FIRST FOURTH_MULTI_DRT=FOURTH_MULTI 
             SECOND_DRT=SECOND THIRD_DRT=THIRD
 FIFTH_DRTHTEST_DRT=FIFTH_DRTHTEST FIRST_DRT=FIRST FOURTH_MULTI_DRT=FOURTH_MULTI SECOND_DRT=SECOND THIRD_DRT=THIRD
 102        
 103        options symbolgen;
 104        proc datasets lib=work nodetails nolist;
 SYMBOLGEN:  Macro variable RENAME_LIST resolves to FIFTH_DRTHTEST_DRT=FIFTH_DRTHTEST FIRST_DRT=FIRST FOURTH_MULTI_DRT=FOURTH_MULTI 
             SECOND_DRT=SECOND THIRD_DRT=THIRD
 105        change &amp;amp;rename_list;
 106        quit;
 
 &lt;FONT size="4" color="#FF0000"&gt;&lt;STRONG&gt;NOTE: Changing the name WORK.FIFTH_DRTHTEST_DRT to WORK.FIFTH_DRTHTEST (memtype=DATA).
 NOTE: Changing the name WORK.FIRST_DRT to WORK.FIRST (memtype=DATA).
 NOTE: Changing the name WORK.FOURTH_MULTI_DRT to WORK.FOURTH_MULTI (memtype=DATA).
 NOTE: Changing the name WORK.SECOND_DRT to WORK.SECOND (memtype=DATA).
 NOTE: Changing the name WORK.THIRD_DRT to WORK.THIRD (memtype=DATA).&lt;/STRONG&gt;&lt;/FONT&gt;
 NOTE: PROCEDURE DATASETS used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              364.06k
       OS Memory           25508.00k
       Timestamp           10/11/2022 11:42:16 PM
       Step Count                        163  Switch Count  20
       Page Faults                       0
       Page Reclaims                     48
       Page Swaps                        0
       Voluntary Context Switches        90
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
       
 
 107        options nosymbolgen;
 108        
 109        
 110        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 120        
 User: fkhurshed
&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/428067"&gt;@Zeus_Olympus&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a library named TEST where all datasets names have a common suffix _DRT i.e.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First_DRT&lt;/P&gt;
&lt;P&gt;Second_DRT&lt;/P&gt;
&lt;P&gt;Third_DRT&lt;/P&gt;
&lt;P&gt;etc...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to rename all of the datasets to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First&lt;/P&gt;
&lt;P&gt;Second&lt;/P&gt;
&lt;P&gt;Third&lt;/P&gt;
&lt;P&gt;etc.&lt;/P&gt;
&lt;P&gt;without the common suffix&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any advice would be more than welcome&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanking you in advance&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Oct 2022 23:42:55 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-10-11T23:42:55Z</dc:date>
    <item>
      <title>Rename all dataset names in a library by dropping the  common suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-dataset-names-in-a-library-by-dropping-the-common/m-p/837836#M331295</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a library named TEST where all datasets names have a common suffix _DRT i.e.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First_DRT&lt;/P&gt;&lt;P&gt;Second_DRT&lt;/P&gt;&lt;P&gt;Third_DRT&lt;/P&gt;&lt;P&gt;etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to rename all of the datasets to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First&lt;/P&gt;&lt;P&gt;Second&lt;/P&gt;&lt;P&gt;Third&lt;/P&gt;&lt;P&gt;etc.&lt;/P&gt;&lt;P&gt;without the common suffix&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advice would be more than welcome&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanking you in advance&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 12:37:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-dataset-names-in-a-library-by-dropping-the-common/m-p/837836#M331295</guid>
      <dc:creator>Zeus_Olympus</dc:creator>
      <dc:date>2022-10-11T12:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all dataset names in a library by dropping the  common suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-dataset-names-in-a-library-by-dropping-the-common/m-p/837838#M331296</link>
      <description>&lt;P&gt;I would build a SAS program (daa step) that reads SASHELP,VTABLE, filtering on your suffix.&lt;/P&gt;
&lt;P&gt;Then (in the data step) generate dynamically PROC DATASETS code for renaming, using CALL EXECUTE.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 12:39:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-dataset-names-in-a-library-by-dropping-the-common/m-p/837838#M331296</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2022-10-11T12:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all dataset names in a library by dropping the  common suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-dataset-names-in-a-library-by-dropping-the-common/m-p/837872#M331315</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I would build a SAS program (daa step) that reads SASHELP,VTABLE, filtering on your suffix.&lt;/P&gt;
&lt;P&gt;Then (in the data step) generate dynamically PROC DATASETS code for renaming, using CALL EXECUTE.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;AFTER verifying that there would no duplicate resulting data set names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One of the things about suffixes is they are often used to differentiate between similar items. So what you also have a data set named First_XYZ? Has this been determined before starting this process (for &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/428067"&gt;@Zeus_Olympus&lt;/a&gt; )&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 15:38:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-dataset-names-in-a-library-by-dropping-the-common/m-p/837872#M331315</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-11T15:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all dataset names in a library by dropping the  common suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-dataset-names-in-a-library-by-dropping-the-common/m-p/837958#M331337</link>
      <description>&lt;P&gt;Yes, indeed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is a fixed and known suffix (_DRT) before any coding.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 23:14:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-dataset-names-in-a-library-by-dropping-the-common/m-p/837958#M331337</guid>
      <dc:creator>Zeus_Olympus</dc:creator>
      <dc:date>2022-10-11T23:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: Rename all dataset names in a library by dropping the  common suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-all-dataset-names-in-a-library-by-dropping-the-common/m-p/837962#M331340</link>
      <description>&lt;P&gt;If this was all in WORK, this is how I would do it. Note this works for a smaller amount of data sets (a few hundred). If the macro variable gets too big then a data step/call execute approach is appropriate instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*delete fake data to avoid issues;
proc datasets nodetails nolist;
delete first second third fourth_multi fifth_drthtest;
quit;

*create fake data for testing;
data first_drt;
set sashelp.class;
data second_drt;
set sashelp.class;
data third_drt;
set sashelp.class;
run;
data fourth_multi_drt;
set sashelp.class;
run;
data fifth_drthtest_drt;
set sashelp.class;
run;


*create a macro variable with the new and old names;
proc sql NOPRINT;
select catx("=", /*separator between name and new name*/
            memname,  /*original name*/
            substr(memname, 1, length(memname)-4) /*new name, 4 is length of suffix to remove*/
            ) into :rename_list separated by " "
from sashelp.vtable 
where libname='WORK' and memname like '%_DRT';
quit;

*display macro variable for confirmation;
%put &amp;amp;rename_list.;

options symbolgen;
proc datasets lib=work nodetails nolist;
change &amp;amp;rename_list;
quit;
options nosymbolgen;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt;1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 SYMBOLGEN:  Macro variable _SASWSTEMP_ resolves to /home/fkhurshed/.sasstudio/.images/d3a117db-e70b-4b05-aa58-1ef8b16a1397
 SYMBOLGEN:  Some characters in the above value which were subject to macro quoting have been unquoted for printing.
 SYMBOLGEN:  Macro variable GRAPHINIT resolves to GOPTIONS RESET=ALL GSFNAME=_GSFNAME;
 68         
 69         *delete fake data to avoid issues;
 70         proc datasets nodetails nolist;
 71         delete first second third fourth_multi fifth_drthtest;
 72         quit;
 
 NOTE: Deleting WORK.FIRST (memtype=DATA).
 NOTE: Deleting WORK.SECOND (memtype=DATA).
 NOTE: Deleting WORK.THIRD (memtype=DATA).
 NOTE: Deleting WORK.FOURTH_MULTI (memtype=DATA).
 NOTE: Deleting WORK.FIFTH_DRTHTEST (memtype=DATA).
 NOTE: PROCEDURE DATASETS used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              362.18k
       OS Memory           25252.00k
       Timestamp           10/11/2022 11:42:16 PM
       Step Count                        156  Switch Count  10
       Page Faults                       0
       Page Reclaims                     57
       Page Swaps                        0
       Voluntary Context Switches        45
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
       
 
 73         
 74         *create fake data for testing;
 75         data first_drt;
 76         set sashelp.class;
 
 NOTE: There were 19 observations read from the data set SASHELP.CLASS.
 NOTE: The data set WORK.FIRST_DRT has 19 observations and 5 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              685.21k
       OS Memory           25508.00k
       Timestamp           10/11/2022 11:42:16 PM
       Step Count                        157  Switch Count  2
       Page Faults                       0
       Page Reclaims                     124
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 77         data second_drt;
 
 78         set sashelp.class;
 
 NOTE: There were 19 observations read from the data set SASHELP.CLASS.
 NOTE: The data set WORK.SECOND_DRT has 19 observations and 5 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              684.84k
       OS Memory           25508.00k
       Timestamp           10/11/2022 11:42:16 PM
       Step Count                        158  Switch Count  2
       Page Faults                       0
       Page Reclaims                     90
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 79         data third_drt;
 
 80         set sashelp.class;
 81         run;
 
 NOTE: There were 19 observations read from the data set SASHELP.CLASS.
 NOTE: The data set WORK.THIRD_DRT has 19 observations and 5 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.01 seconds
       system cpu time     0.00 seconds
       memory              685.21k
       OS Memory           25508.00k
       Timestamp           10/11/2022 11:42:16 PM
       Step Count                        159  Switch Count  2
       Page Faults                       0
       Page Reclaims                     88
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 82         data fourth_multi_drt;
 83         set sashelp.class;
 84         run;
 
 NOTE: There were 19 observations read from the data set SASHELP.CLASS.
 NOTE: The data set WORK.FOURTH_MULTI_DRT has 19 observations and 5 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              685.21k
       OS Memory           25508.00k
       Timestamp           10/11/2022 11:42:16 PM
       Step Count                        160  Switch Count  2
       Page Faults                       0
       Page Reclaims                     88
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 85         data fifth_drthtest_drt;
 86         set sashelp.class;
 87         run;
 
 NOTE: There were 19 observations read from the data set SASHELP.CLASS.
 NOTE: The data set WORK.FIFTH_DRTHTEST_DRT has 19 observations and 5 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              684.84k
       OS Memory           25508.00k
       Timestamp           10/11/2022 11:42:16 PM
       Step Count                        161  Switch Count  2
       Page Faults                       0
       Page Reclaims                     88
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 88         
 89         
 90         *create a macro variable with the new and old names;
 91         proc sql NOPRINT;
 92         select catx("=", /*separator between name and new name*/
 93                     memname,  /*original name*/
 94                     substr(memname, 1, length(memname)-4) /*new name, 4 is length of suffix to remove*/
 95                     ) into :rename_list separated by " "
 96         from sashelp.vtable
 97         where libname='WORK' and memname like '%_DRT';
 98         quit;
 NOTE: PROCEDURE SQL used (Total process time):
       real time           0.00 seconds
       user cpu time       0.01 seconds
       system cpu time     0.01 seconds
       memory              5266.28k
       OS Memory           30372.00k
       Timestamp           10/11/2022 11:42:16 PM
       Step Count                        162  Switch Count  0
       Page Faults                       0
       Page Reclaims                     44
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           0
       
 
 99         
 100        *display macro variable for confirmation;
 101        %put &amp;amp;rename_list.;
 SYMBOLGEN:  Macro variable RENAME_LIST resolves to FIFTH_DRTHTEST_DRT=FIFTH_DRTHTEST FIRST_DRT=FIRST FOURTH_MULTI_DRT=FOURTH_MULTI 
             SECOND_DRT=SECOND THIRD_DRT=THIRD
 FIFTH_DRTHTEST_DRT=FIFTH_DRTHTEST FIRST_DRT=FIRST FOURTH_MULTI_DRT=FOURTH_MULTI SECOND_DRT=SECOND THIRD_DRT=THIRD
 102        
 103        options symbolgen;
 104        proc datasets lib=work nodetails nolist;
 SYMBOLGEN:  Macro variable RENAME_LIST resolves to FIFTH_DRTHTEST_DRT=FIFTH_DRTHTEST FIRST_DRT=FIRST FOURTH_MULTI_DRT=FOURTH_MULTI 
             SECOND_DRT=SECOND THIRD_DRT=THIRD
 105        change &amp;amp;rename_list;
 106        quit;
 
 &lt;FONT size="4" color="#FF0000"&gt;&lt;STRONG&gt;NOTE: Changing the name WORK.FIFTH_DRTHTEST_DRT to WORK.FIFTH_DRTHTEST (memtype=DATA).
 NOTE: Changing the name WORK.FIRST_DRT to WORK.FIRST (memtype=DATA).
 NOTE: Changing the name WORK.FOURTH_MULTI_DRT to WORK.FOURTH_MULTI (memtype=DATA).
 NOTE: Changing the name WORK.SECOND_DRT to WORK.SECOND (memtype=DATA).
 NOTE: Changing the name WORK.THIRD_DRT to WORK.THIRD (memtype=DATA).&lt;/STRONG&gt;&lt;/FONT&gt;
 NOTE: PROCEDURE DATASETS used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              364.06k
       OS Memory           25508.00k
       Timestamp           10/11/2022 11:42:16 PM
       Step Count                        163  Switch Count  20
       Page Faults                       0
       Page Reclaims                     48
       Page Swaps                        0
       Voluntary Context Switches        90
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
       
 
 107        options nosymbolgen;
 108        
 109        
 110        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 120        
 User: fkhurshed
&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/428067"&gt;@Zeus_Olympus&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a library named TEST where all datasets names have a common suffix _DRT i.e.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First_DRT&lt;/P&gt;
&lt;P&gt;Second_DRT&lt;/P&gt;
&lt;P&gt;Third_DRT&lt;/P&gt;
&lt;P&gt;etc...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to rename all of the datasets to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First&lt;/P&gt;
&lt;P&gt;Second&lt;/P&gt;
&lt;P&gt;Third&lt;/P&gt;
&lt;P&gt;etc.&lt;/P&gt;
&lt;P&gt;without the common suffix&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any advice would be more than welcome&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanking you in advance&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 23:42:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-all-dataset-names-in-a-library-by-dropping-the-common/m-p/837962#M331340</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-10-11T23:42:55Z</dc:date>
    </item>
  </channel>
</rss>

