<?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: interleaving 2 datasets with SET statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/interleaving-2-datasets-with-SET-statement/m-p/16587#M2325</link>
    <description>hello,&lt;BR /&gt;
&lt;BR /&gt;
your final output has only 2 rows because SAS reads sequentially which determines the end of prods file to be "achieved" on the first pass to the data step.&lt;BR /&gt;
&lt;BR /&gt;
you expected on the second pass to the data step that SAS reads the prods file from the beginning, but instead SAS stops execution and this is because SAS reached the end of prods file.&lt;BR /&gt;
&lt;BR /&gt;
one solution is using direct access to read the prods file:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data prods_dates;&lt;BR /&gt;
set dates;&lt;BR /&gt;
i=1;&lt;BR /&gt;
do order=1 to LAST;&lt;BR /&gt;
set prods point=i nobs=LAST ;&lt;BR /&gt;
output;&lt;BR /&gt;
i+1;&lt;BR /&gt;
end;&lt;BR /&gt;
RUN;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Marius</description>
    <pubDate>Thu, 24 Feb 2011 11:26:32 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2011-02-24T11:26:32Z</dc:date>
    <item>
      <title>interleaving 2 datasets with SET statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/interleaving-2-datasets-with-SET-statement/m-p/16586#M2324</link>
      <description>why does my final output dataset has only 2 rows and not 6 (for each date a prod line)?&lt;BR /&gt;
&lt;BR /&gt;
data dates;&lt;BR /&gt;
 input date $ ;&lt;BR /&gt;
cards;&lt;BR /&gt;
01/02/2010&lt;BR /&gt;
02/02/2010&lt;BR /&gt;
03/02/2010&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data prods;&lt;BR /&gt;
 input prod $ ;&lt;BR /&gt;
cards;&lt;BR /&gt;
PRODA&lt;BR /&gt;
PRODB&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data prods_dates;&lt;BR /&gt;
 set dates;&lt;BR /&gt;
  do order=1 to LAST;&lt;BR /&gt;
    set prods nobs=LAST;&lt;BR /&gt;
    output;&lt;BR /&gt;
  end;&lt;BR /&gt;
RUN;</description>
      <pubDate>Thu, 24 Feb 2011 10:56:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/interleaving-2-datasets-with-SET-statement/m-p/16586#M2324</guid>
      <dc:creator>Jaheuk</dc:creator>
      <dc:date>2011-02-24T10:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: interleaving 2 datasets with SET statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/interleaving-2-datasets-with-SET-statement/m-p/16587#M2325</link>
      <description>hello,&lt;BR /&gt;
&lt;BR /&gt;
your final output has only 2 rows because SAS reads sequentially which determines the end of prods file to be "achieved" on the first pass to the data step.&lt;BR /&gt;
&lt;BR /&gt;
you expected on the second pass to the data step that SAS reads the prods file from the beginning, but instead SAS stops execution and this is because SAS reached the end of prods file.&lt;BR /&gt;
&lt;BR /&gt;
one solution is using direct access to read the prods file:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data prods_dates;&lt;BR /&gt;
set dates;&lt;BR /&gt;
i=1;&lt;BR /&gt;
do order=1 to LAST;&lt;BR /&gt;
set prods point=i nobs=LAST ;&lt;BR /&gt;
output;&lt;BR /&gt;
i+1;&lt;BR /&gt;
end;&lt;BR /&gt;
RUN;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Marius</description>
      <pubDate>Thu, 24 Feb 2011 11:26:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/interleaving-2-datasets-with-SET-statement/m-p/16587#M2325</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-24T11:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: interleaving 2 datasets with SET statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/interleaving-2-datasets-with-SET-statement/m-p/16588#M2326</link>
      <description>The SAS variable LAST is incremented until it reaches the NOBS= value (based on WORK.PRODS).  Then, unless you were to reset the value to LAST=0;  outside your DO &lt;EXPRESSION&gt;/END loop, the "expression" condition will never be met again.&lt;BR /&gt;
&lt;BR /&gt;
For self-diagnosis, suggest you add the following statement at various points in your SAS program to display all SAS variable values:&lt;BR /&gt;
&lt;BR /&gt;
PUTLOG '&amp;gt;DIAG&amp;gt;' / _ALL_;&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;/EXPRESSION&gt;</description>
      <pubDate>Thu, 24 Feb 2011 12:27:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/interleaving-2-datasets-with-SET-statement/m-p/16588#M2326</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-02-24T12:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: interleaving 2 datasets with SET statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/interleaving-2-datasets-with-SET-statement/m-p/16589#M2327</link>
      <description>Marius, thx for solution and reason why it did not work  &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
CU,&lt;BR /&gt;
Herman</description>
      <pubDate>Thu, 24 Feb 2011 15:35:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/interleaving-2-datasets-with-SET-statement/m-p/16589#M2327</guid>
      <dc:creator>Jaheuk</dc:creator>
      <dc:date>2011-02-24T15:35:10Z</dc:date>
    </item>
  </channel>
</rss>

