<?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 variable using macro and do loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Rename-variable-using-macro-and-do-loop/m-p/812329#M320502</link>
    <description>&lt;P&gt;You want to rename with using the RENAME statement or option? And without using the variable name?&lt;/P&gt;
&lt;P&gt;This makes no sense at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;I want to create a macro to rename all variables in sashelp.cars with suffix 1.&lt;/P&gt;
&lt;P&gt;For eg. MODEL will be MODEL1.&lt;/P&gt;
&lt;P&gt;PS: I Don't want to use renaming (eg. rename model = model1). I want to find count of variable in the dataset sashelp.cars and use do loop and then rename inside macro (also don't want to use variable name directly while renaming).&lt;/P&gt;
&lt;P&gt;Any easy approach to do this?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
    <pubDate>Tue, 10 May 2022 08:55:39 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2022-05-10T08:55:39Z</dc:date>
    <item>
      <title>Rename variable using macro and do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variable-using-macro-and-do-loop/m-p/812306#M320493</link>
      <description>&lt;P&gt;I want to create a macro to rename all variables in sashelp.cars with suffix 1.&lt;/P&gt;&lt;P&gt;For eg. MODEL will be MODEL1.&lt;/P&gt;&lt;P&gt;PS: I Don't want to use renaming (eg. rename model = model1). I want to find count of variable in the dataset sashelp.cars and use do loop and then rename inside macro (also don't want to use variable name directly while renaming).&lt;/P&gt;&lt;P&gt;Any easy approach to do this?&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 07:24:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variable-using-macro-and-do-loop/m-p/812306#M320493</guid>
      <dc:creator>gahlot1999</dc:creator>
      <dc:date>2022-05-10T07:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variable using macro and do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variable-using-macro-and-do-loop/m-p/812329#M320502</link>
      <description>&lt;P&gt;You want to rename with using the RENAME statement or option? And without using the variable name?&lt;/P&gt;
&lt;P&gt;This makes no sense at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;I want to create a macro to rename all variables in sashelp.cars with suffix 1.&lt;/P&gt;
&lt;P&gt;For eg. MODEL will be MODEL1.&lt;/P&gt;
&lt;P&gt;PS: I Don't want to use renaming (eg. rename model = model1). I want to find count of variable in the dataset sashelp.cars and use do loop and then rename inside macro (also don't want to use variable name directly while renaming).&lt;/P&gt;
&lt;P&gt;Any easy approach to do this?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 10 May 2022 08:55:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variable-using-macro-and-do-loop/m-p/812329#M320502</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2022-05-10T08:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variable using macro and do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variable-using-macro-and-do-loop/m-p/812362#M320521</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/424399"&gt;@gahlot1999&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS: I Don't want to use renaming (eg. rename model = model1). I want to find count of variable in the dataset sashelp.cars and use do loop and then rename inside macro (also don't want to use variable name directly while renaming).&lt;/P&gt;
&lt;P&gt;Any easy approach to do this?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why this restriction? Why are you saying I can only use certain parts of SAS to do this and not other parts of SAS?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You realize that you can't rename variables in SASHELP.CARS because users do not have WRITE permission to any SASHELP data sets. You could copy the data set into the WORK library.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, this is easily done without a macro and without specifying an explicit loop, but with the RENAME statement and with a single macro variable.&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 11:50:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variable-using-macro-and-do-loop/m-p/812362#M320521</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-10T11:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variable using macro and do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variable-using-macro-and-do-loop/m-p/812366#M320523</link>
      <description>&lt;P&gt;No macro needed, only a macro variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select trim(name) !! "=" !! trim(name) !! "1" into :renames separated by " "
from dictionary.columns
where libname = "SASHELP" and memname = "CARS";
quit;

%put &amp;amp;renames.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The resulting macro variable can be used in a RENAME statement or RENAME= dataset option.&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2022 11:49:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variable-using-macro-and-do-loop/m-p/812366#M320523</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-05-10T11:49:18Z</dc:date>
    </item>
  </channel>
</rss>

