<?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 and array operation using a loop in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Rename-columns-and-array-operation-using-a-loop/m-p/341116#M22605</link>
    <description>&lt;P&gt;You are mixing up usage here. &amp;nbsp;Columns names are for identification in the programming, they are not meant to be used as data. &amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Mar 2017 09:14:50 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-03-15T09:14:50Z</dc:date>
    <item>
      <title>Rename columns and array operation using a loop</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Rename-columns-and-array-operation-using-a-loop/m-p/341040#M22599</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* data have */
Class Time_0 Time_1 Time_2
  A      1     2      4
  B      0     3      9
  C      3     6      0

/* data want */
Class _01 _12
  A    2    2
  B    1    3
  C    2    0&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Rule 1: In data 'want',&amp;nbsp;column '_01' = column 'Time_1' / '&lt;SPAN&gt;Time_0' from data 'have'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;'_12' = 'Time_2' / 'Time_1'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;....&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Rule 2: If&amp;nbsp;divisor = 0 then result = 1.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Because my actual data have more than 100 'time' columns: Time_0-Time_&amp;amp;Num &amp;nbsp;(Num is a global macro variable), would prefer using a loop rather than hardcode it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2017 02:38:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Rename-columns-and-array-operation-using-a-loop/m-p/341040#M22599</guid>
      <dc:creator>ayin</dc:creator>
      <dc:date>2017-03-15T02:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: Rename columns and array operation using a loop</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Rename-columns-and-array-operation-using-a-loop/m-p/341051#M22600</link>
      <description>&lt;P&gt;The naming of the new columns might be a little different here. &amp;nbsp;The name is based on the numerator (but not the denominator):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;array times {0:&amp;amp;num} time_0 - time_&amp;amp;num;&lt;/P&gt;
&lt;P&gt;array ratios {&amp;amp;num} _001 - _&amp;amp;num;&lt;/P&gt;
&lt;P&gt;do i=1 to &amp;amp;num;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if times{i-1} = 0 then ratios{i)=0;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;else ratios{i} = times{i} / times{i-1};&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;drop i;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you would like, you can also drop all the TIME variables as well.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2017 03:13:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Rename-columns-and-array-operation-using-a-loop/m-p/341051#M22600</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-15T03:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: Rename columns and array operation using a loop</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Rename-columns-and-array-operation-using-a-loop/m-p/341116#M22605</link>
      <description>&lt;P&gt;You are mixing up usage here. &amp;nbsp;Columns names are for identification in the programming, they are not meant to be used as data. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2017 09:14:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Rename-columns-and-array-operation-using-a-loop/m-p/341116#M22605</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-03-15T09:14:50Z</dc:date>
    </item>
  </channel>
</rss>

