<?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 columns in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Rename-columns/m-p/557616#M74783</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/34400"&gt;@Tal&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I receive a table beginning of each month&amp;nbsp; out of which i create a&amp;nbsp;&amp;nbsp; master dataset (append each table to the previous month one) &lt;BR /&gt;but the&amp;nbsp; problem is one of the&amp;nbsp; field's name &amp;nbsp;in&amp;nbsp; that table&amp;nbsp; changes every time&amp;nbsp; a&amp;nbsp; new&amp;nbsp; table&amp;nbsp; arrives and so does&amp;nbsp;the format of that column. For example last&amp;nbsp; month&amp;nbsp; the dataset&amp;nbsp; had&amp;nbsp; these columns :var1 var2&amp;nbsp; var3 where var2 has numeric values and&amp;nbsp; this month the&amp;nbsp;&amp;nbsp; headers were var1 var2a var3&amp;nbsp; and&amp;nbsp; var2a had char values so&amp;nbsp; I always have to manually change the&amp;nbsp;name and &amp;nbsp;convert&amp;nbsp;the value of &amp;nbsp;the second field&amp;nbsp; before appending&amp;nbsp; the new&amp;nbsp; table and&amp;nbsp; there is no pattern as&amp;nbsp; to how they&amp;nbsp; named&amp;nbsp; that variable so next month it&amp;nbsp; could be&amp;nbsp; var1, varabc,var3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wanted to automate this process&amp;nbsp; so the conversion of the second&amp;nbsp; column and&amp;nbsp; the appending is done with only pushing&amp;nbsp;&amp;nbsp; a&amp;nbsp; button&amp;nbsp; but&amp;nbsp;&amp;nbsp; my&amp;nbsp; confusion is&amp;nbsp; about that&amp;nbsp; second&amp;nbsp; header. Is it possible that SAS picks only the second&amp;nbsp; field&amp;nbsp; of&amp;nbsp; a&amp;nbsp; certain&amp;nbsp; dataset and&amp;nbsp; names&amp;nbsp; it lets say var2&amp;nbsp; without&amp;nbsp; worrying&amp;nbsp; what the original name of that field is?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any&amp;nbsp; suggestions appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Thx&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;How are you reading the data into SAS?&lt;/P&gt;
&lt;P&gt;If your are relying on Proc Import this one reason not to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use a data step to read the data and as long as the column values behave the column name, length, format and informat are as you assign them in the data step. Once you have code to read one file then all you need to do is change the name of the input file and possibly the name of the output data set from the data step. The changed data set name wouldn't likely be needed if you are appending to an existing data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your data is some sort of text file and proc import "works" to read it, then SAS wrote a data step for you. Copy it from the log and edit to the names and properties you need.&lt;/P&gt;</description>
    <pubDate>Thu, 09 May 2019 21:17:33 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-05-09T21:17:33Z</dc:date>
    <item>
      <title>Rename columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rename-columns/m-p/557608#M74782</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I receive a table beginning of each month&amp;nbsp; out of which i create a&amp;nbsp;&amp;nbsp; master dataset (append each table to the previous month one) &lt;BR /&gt;but the&amp;nbsp; problem is one of the&amp;nbsp; field's name &amp;nbsp;in&amp;nbsp; that table&amp;nbsp; changes every time&amp;nbsp; a&amp;nbsp; new&amp;nbsp; table&amp;nbsp; arrives and so does&amp;nbsp;the format of that column. For example last&amp;nbsp; month&amp;nbsp; the dataset&amp;nbsp; had&amp;nbsp; these columns :var1 var2&amp;nbsp; var3 where var2 has numeric values and&amp;nbsp; this month the&amp;nbsp;&amp;nbsp; headers were var1 var2a var3&amp;nbsp; and&amp;nbsp; var2a had char values so&amp;nbsp; I always have to manually change the&amp;nbsp;name and &amp;nbsp;convert&amp;nbsp;the value of &amp;nbsp;the second field&amp;nbsp; before appending&amp;nbsp; the new&amp;nbsp; table and&amp;nbsp; there is no pattern as&amp;nbsp; to how they&amp;nbsp; named&amp;nbsp; that variable so next month it&amp;nbsp; could be&amp;nbsp; var1, varabc,var3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wanted to automate this process&amp;nbsp; so the conversion of the second&amp;nbsp; column and&amp;nbsp; the appending is done with only pushing&amp;nbsp;&amp;nbsp; a&amp;nbsp; button&amp;nbsp; but&amp;nbsp;&amp;nbsp; my&amp;nbsp; confusion is&amp;nbsp; about that&amp;nbsp; second&amp;nbsp; header. Is it possible that SAS picks only the second&amp;nbsp; field&amp;nbsp; of&amp;nbsp; a&amp;nbsp; certain&amp;nbsp; dataset and&amp;nbsp; names&amp;nbsp; it lets say var2&amp;nbsp; without&amp;nbsp; worrying&amp;nbsp; what the original name of that field is?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any&amp;nbsp; suggestions appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Thx&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 20:44:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rename-columns/m-p/557608#M74782</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2019-05-09T20:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: Rename columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rename-columns/m-p/557616#M74783</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/34400"&gt;@Tal&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I receive a table beginning of each month&amp;nbsp; out of which i create a&amp;nbsp;&amp;nbsp; master dataset (append each table to the previous month one) &lt;BR /&gt;but the&amp;nbsp; problem is one of the&amp;nbsp; field's name &amp;nbsp;in&amp;nbsp; that table&amp;nbsp; changes every time&amp;nbsp; a&amp;nbsp; new&amp;nbsp; table&amp;nbsp; arrives and so does&amp;nbsp;the format of that column. For example last&amp;nbsp; month&amp;nbsp; the dataset&amp;nbsp; had&amp;nbsp; these columns :var1 var2&amp;nbsp; var3 where var2 has numeric values and&amp;nbsp; this month the&amp;nbsp;&amp;nbsp; headers were var1 var2a var3&amp;nbsp; and&amp;nbsp; var2a had char values so&amp;nbsp; I always have to manually change the&amp;nbsp;name and &amp;nbsp;convert&amp;nbsp;the value of &amp;nbsp;the second field&amp;nbsp; before appending&amp;nbsp; the new&amp;nbsp; table and&amp;nbsp; there is no pattern as&amp;nbsp; to how they&amp;nbsp; named&amp;nbsp; that variable so next month it&amp;nbsp; could be&amp;nbsp; var1, varabc,var3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wanted to automate this process&amp;nbsp; so the conversion of the second&amp;nbsp; column and&amp;nbsp; the appending is done with only pushing&amp;nbsp;&amp;nbsp; a&amp;nbsp; button&amp;nbsp; but&amp;nbsp;&amp;nbsp; my&amp;nbsp; confusion is&amp;nbsp; about that&amp;nbsp; second&amp;nbsp; header. Is it possible that SAS picks only the second&amp;nbsp; field&amp;nbsp; of&amp;nbsp; a&amp;nbsp; certain&amp;nbsp; dataset and&amp;nbsp; names&amp;nbsp; it lets say var2&amp;nbsp; without&amp;nbsp; worrying&amp;nbsp; what the original name of that field is?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any&amp;nbsp; suggestions appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Thx&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;How are you reading the data into SAS?&lt;/P&gt;
&lt;P&gt;If your are relying on Proc Import this one reason not to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use a data step to read the data and as long as the column values behave the column name, length, format and informat are as you assign them in the data step. Once you have code to read one file then all you need to do is change the name of the input file and possibly the name of the output data set from the data step. The changed data set name wouldn't likely be needed if you are appending to an existing data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your data is some sort of text file and proc import "works" to read it, then SAS wrote a data step for you. Copy it from the log and edit to the names and properties you need.&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 21:17:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rename-columns/m-p/557616#M74783</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-09T21:17:33Z</dc:date>
    </item>
    <item>
      <title>Re: Rename columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rename-columns/m-p/557943#M74803</link>
      <description>&lt;P&gt;Data is actually&amp;nbsp; coming in excel (three tabs, 4&amp;nbsp; tabs,depends) and&amp;nbsp; i&amp;nbsp; use&amp;nbsp; pcfiles (libname mylib pcfiles.....)to import it into SAS. The tabs are named&amp;nbsp; differently&amp;nbsp; every time i&amp;nbsp; receive&amp;nbsp; this excel creating&amp;nbsp; different datasets&amp;nbsp; after the import but&amp;nbsp; i have a&amp;nbsp; macro&amp;nbsp; that&amp;nbsp; takes care of it (picking all&amp;nbsp; the&amp;nbsp; datasets in my&amp;nbsp; library and&amp;nbsp; appending&amp;nbsp; them)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now the&amp;nbsp; problem is before running&amp;nbsp; that macro&amp;nbsp; some times i&amp;nbsp; have to convert the value&amp;nbsp; of the&amp;nbsp; second&amp;nbsp; field and&amp;nbsp; conversion not&amp;nbsp; a&amp;nbsp; problem&amp;nbsp; as long as&amp;nbsp; that header does not keep changing its name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data&amp;nbsp; in the&amp;nbsp; excel&amp;nbsp; tabs is kinda messy(some titles on the&amp;nbsp; top rows which are always in the second&amp;nbsp; column&amp;nbsp; of the sheets),then empty&amp;nbsp; rows and then&amp;nbsp; data) so when&amp;nbsp; i&amp;nbsp; try&amp;nbsp; importing&amp;nbsp; it that title behaves as&amp;nbsp; the&amp;nbsp; 2nd&amp;nbsp; header in my&amp;nbsp; tables and&amp;nbsp; that title&amp;nbsp; is always different in each&amp;nbsp; tab, every month&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The rest of the&amp;nbsp; headers&amp;nbsp; are ok, always F1,F3,.......F23. It is the second one&amp;nbsp; that messes&amp;nbsp; up and&amp;nbsp; prevents me&amp;nbsp; from&amp;nbsp; automating&amp;nbsp; this so i was hoping SAS is capable of calling&amp;nbsp; the&amp;nbsp; fields in&amp;nbsp; the datasets using&amp;nbsp; indexes&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 May 2019 19:50:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rename-columns/m-p/557943#M74803</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2019-05-10T19:50:30Z</dc:date>
    </item>
  </channel>
</rss>

