<?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 repeated obs in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/repeated-obs/m-p/280777#M56797</link>
    <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am unable to understand how this program is giving output for 8 observation and repeating 1, 2 and 5???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data input;&lt;BR /&gt;infile datalines;&lt;BR /&gt;input Var1 $ Var2 $;&lt;BR /&gt;datalines;&lt;BR /&gt;A one&lt;BR /&gt;A two&lt;BR /&gt;B three&lt;BR /&gt;C four&lt;BR /&gt;A five&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;BR /&gt;data one&amp;nbsp;two;&lt;BR /&gt; set WORK.INPUT;&lt;BR /&gt;count= _n_;&lt;BR /&gt; if Var1='A' then output WORK.ONEs;&lt;BR /&gt;output;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Jun 2016 13:33:37 GMT</pubDate>
    <dc:creator>Rahul_SAS</dc:creator>
    <dc:date>2016-06-28T13:33:37Z</dc:date>
    <item>
      <title>repeated obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeated-obs/m-p/280777#M56797</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am unable to understand how this program is giving output for 8 observation and repeating 1, 2 and 5???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data input;&lt;BR /&gt;infile datalines;&lt;BR /&gt;input Var1 $ Var2 $;&lt;BR /&gt;datalines;&lt;BR /&gt;A one&lt;BR /&gt;A two&lt;BR /&gt;B three&lt;BR /&gt;C four&lt;BR /&gt;A five&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;BR /&gt;data one&amp;nbsp;two;&lt;BR /&gt; set WORK.INPUT;&lt;BR /&gt;count= _n_;&lt;BR /&gt; if Var1='A' then output WORK.ONEs;&lt;BR /&gt;output;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 13:33:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeated-obs/m-p/280777#M56797</guid>
      <dc:creator>Rahul_SAS</dc:creator>
      <dc:date>2016-06-28T13:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: repeated obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeated-obs/m-p/280788#M56804</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data step processes the input dataset row by row.&lt;/P&gt;
&lt;P&gt;If there is no explicit output instruction in the code,&lt;/P&gt;
&lt;P&gt;the currently processed row (*) is output when the interpreter&lt;/P&gt;
&lt;P&gt;hits the run instruction. If there remains rows to process, there&lt;/P&gt;
&lt;P&gt;is an implicit loop and the instructions in the data step are&lt;/P&gt;
&lt;P&gt;executed again for the next row of the input dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(*) More precisely the program data vector (PDV) wich is SAS terminology to&lt;/P&gt;
&lt;P&gt;indicate the data being processed (row extracted from the input dataset + newly&lt;/P&gt;
&lt;P&gt;created variables).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On the other hand, when the code in the data step contains some&lt;/P&gt;
&lt;P&gt;output instructions, those determine when to output new lines in the&lt;/P&gt;
&lt;P&gt;created dataset and the run instruction does not implicitely output&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data anymore.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So in your code, for each input row where Var1='A', the instruction&lt;/P&gt;
&lt;P&gt;output WORK.ONE&lt;/P&gt;
&lt;P&gt;creates a new row in table ONE.&lt;/P&gt;
&lt;P&gt;The following output instruction creates a new row in both output datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With 3 rows having Var1='A' and two rows where Var1 &amp;lt;&amp;gt; 'A',&lt;/P&gt;
&lt;P&gt;the ONE dataset will have : 3x2+2=8 rows.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 14:00:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeated-obs/m-p/280788#M56804</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2016-06-28T14:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: repeated obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/repeated-obs/m-p/280790#M56805</link>
      <description>&lt;P&gt;There are two output statements.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The one executes for ALL records. The second is conditional and only executes if the variable is A, records 1,2 and 5 in your case.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 14:00:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/repeated-obs/m-p/280790#M56805</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-06-28T14:00:52Z</dc:date>
    </item>
  </channel>
</rss>

