<?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: Horizontal loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Horizontal-loop/m-p/406850#M99124</link>
    <description>&lt;PRE&gt;data want;
  set have;
  array x{10};
  do i=1 to 10;
    s=s+ifn(x{i}&amp;gt;5,x{i},0);
  end;
run;&lt;/PRE&gt;</description>
    <pubDate>Tue, 24 Oct 2017 09:04:33 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-10-24T09:04:33Z</dc:date>
    <item>
      <title>Horizontal loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Horizontal-loop/m-p/406801#M99102</link>
      <description>&lt;P&gt;Hi, I have a question. How can I write a code in order to loop horizontally.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I must sum the values&amp;nbsp;of the X1 - X10&amp;nbsp; &amp;nbsp;{S = sum(of X1- X10)} but depending on their value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For instance, X{i} is omitted&amp;nbsp; if it is less than 5.&lt;/P&gt;&lt;P&gt;or,&lt;/P&gt;&lt;P&gt;if the column name equals "Class_A" then the appropriate value of the column must be added to the sum.&lt;/P&gt;&lt;P&gt;Thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 06:17:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Horizontal-loop/m-p/406801#M99102</guid>
      <dc:creator>Garik</dc:creator>
      <dc:date>2017-10-24T06:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: Horizontal loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Horizontal-loop/m-p/406802#M99103</link>
      <description>You will want to look up the syntax of array, iterative do-loop and the if-statement.&lt;BR /&gt;&lt;BR /&gt;Post the code you have.</description>
      <pubDate>Tue, 24 Oct 2017 06:39:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Horizontal-loop/m-p/406802#M99103</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2017-10-24T06:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: Horizontal loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Horizontal-loop/m-p/406850#M99124</link>
      <description>&lt;PRE&gt;data want;
  set have;
  array x{10};
  do i=1 to 10;
    s=s+ifn(x{i}&amp;gt;5,x{i},0);
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Oct 2017 09:04:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Horizontal-loop/m-p/406850#M99124</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-24T09:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: Horizontal loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Horizontal-loop/m-p/406878#M99134</link>
      <description>&lt;P&gt;Whenever I see someone doing/wanting to do a horizontal loop I immediately say to myself&amp;nbsp;"that's spreadsheet thinking". In the long run you're much better off transposing your variables so you have a long and thin data set. For example what if, next time you want to run your code you have 15 variables instead of 10? You'll have to edit your code and that will become tedious and error-prone over time - much better to transpose it and use by-group processing which will remove that issue.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 10:15:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Horizontal-loop/m-p/406878#M99134</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-10-24T10:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Horizontal loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Horizontal-loop/m-p/406929#M99141</link>
      <description>&lt;P&gt;Hi. if the dataset contains 20 mln rows and 245 columns! would the transposing work?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 13:27:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Horizontal-loop/m-p/406929#M99141</guid>
      <dc:creator>Garik</dc:creator>
      <dc:date>2017-10-24T13:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: Horizontal loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Horizontal-loop/m-p/406937#M99143</link>
      <description>&lt;P&gt;Transposing from wide to long is no problem, as SAS only needs to treat one record at a time. And if you can set a rule for values that can be dropped (ie missing or 0), you might even end up with a physically smaller dataset.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 13:46:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Horizontal-loop/m-p/406937#M99143</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-24T13:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: Horizontal loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Horizontal-loop/m-p/406981#M99149</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;says a long data set will (in my experience) usually be more efficient than a wide one even with more rows. Having said that if you were my client I'd be looking very hard at this data - with 20 million rows and 250 variables there's probably room for some reorganisation which would make processing more efficient and save on space.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've been doing this sort of thing professionally for 30 years and turned numerous clients data around from wide to long - they're usually sceptical at first but once they see the transposed data sets in action they're quickly turned around &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 15:40:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Horizontal-loop/m-p/406981#M99149</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-10-24T15:40:05Z</dc:date>
    </item>
  </channel>
</rss>

