<?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: Do loop in All Things Community</title>
    <link>https://communities.sas.com/t5/All-Things-Community/Do-loop/m-p/232646#M1157</link>
    <description>&lt;P&gt;You've mentioned that your data has 2 variables and 3 records each. Does that mean the pattern repeats ? &amp;nbsp;If it doesn't repeat, why do you need a "Do" loop ? If it repeats, do the names remain the same through out as Planttype1 and Planttype2 ?&lt;/P&gt;</description>
    <pubDate>Sun, 01 Nov 2015 15:56:12 GMT</pubDate>
    <dc:creator>kannand</dc:creator>
    <dc:date>2015-11-01T15:56:12Z</dc:date>
    <item>
      <title>Do loop</title>
      <link>https://communities.sas.com/t5/All-Things-Community/Do-loop/m-p/232644#M1155</link>
      <description>&lt;P&gt;Hi I have a problem like this.&lt;/P&gt;&lt;P&gt;My dataset contains 2 variables 3 Observation&amp;nbsp;each i want to put Planttype1 and Planttype2 in each observation.&lt;/P&gt;&lt;P&gt;[dateset Variables ]&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;datalines;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;11 22&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;12 23&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;13 24&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[I want ]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Obs name Valu1 name1 Value2&lt;BR /&gt;1 Planttype1 11 Planttype2 22&lt;BR /&gt;2 Planttype1 12 Planttype2 23&lt;BR /&gt;3 Planttype1 13 Planttype2 24&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This below code is working fine ,but i feel there is to much of code i have used ,how can i optimized this ?hh&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data newdata;&lt;BR /&gt;Retain name Valu1 Planttype2 name1 ;&lt;BR /&gt;input Valu1 Value2;&lt;BR /&gt;do name = 'Planttype1';&lt;BR /&gt;do i = 1 to 1;&lt;BR /&gt;do name1 = 'Planttype2';&lt;BR /&gt;do p = 1 to 1;&lt;BR /&gt;output;&lt;BR /&gt;End;&lt;BR /&gt;End;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;Drop i p;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;datalines;&lt;BR /&gt;11 22&lt;BR /&gt;12 23&lt;BR /&gt;13 24&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2015 15:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/Do-loop/m-p/232644#M1155</guid>
      <dc:creator>pearsoninst</dc:creator>
      <dc:date>2015-11-01T15:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/All-Things-Community/Do-loop/m-p/232645#M1156</link>
      <description>&lt;P&gt;Huh???&lt;/P&gt;
&lt;P&gt;To read your original data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input plantype1 plantype2;
datalines;
11 22
12 23
13 24
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To convert to the new structure from there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have ;
  name='Plantype1';
  name1='Plantype2';
  rename plantype1=valu1 plantype2=valu2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The obvious question is WHY would you want to make this change?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also why name series of variables where the number start being appended on the second name in the series. like X, X1, X2, instead of X1, X2, X3. If you use the later convention then you can use variable lists. &amp;nbsp;Also it will be less confusing to the users of the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2015 15:52:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/Do-loop/m-p/232645#M1156</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-11-01T15:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop</title>
      <link>https://communities.sas.com/t5/All-Things-Community/Do-loop/m-p/232646#M1157</link>
      <description>&lt;P&gt;You've mentioned that your data has 2 variables and 3 records each. Does that mean the pattern repeats ? &amp;nbsp;If it doesn't repeat, why do you need a "Do" loop ? If it repeats, do the names remain the same through out as Planttype1 and Planttype2 ?&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2015 15:56:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/Do-loop/m-p/232646#M1157</guid>
      <dc:creator>kannand</dc:creator>
      <dc:date>2015-11-01T15:56:12Z</dc:date>
    </item>
  </channel>
</rss>

