<?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: set a dataset many times within a data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/set-a-dataset-many-times-within-a-data-step/m-p/502126#M133999</link>
    <description>&lt;P&gt;why?&lt;/P&gt;</description>
    <pubDate>Sat, 06 Oct 2018 14:43:55 GMT</pubDate>
    <dc:creator>ShufeGuoding</dc:creator>
    <dc:date>2018-10-06T14:43:55Z</dc:date>
    <item>
      <title>set a dataset many times within a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/set-a-dataset-many-times-within-a-data-step/m-p/502124#M133997</link>
      <description>&lt;P&gt;What's the difference between the results from two data step in the following?&lt;/P&gt;
&lt;P&gt;data s;&lt;BR /&gt;do n=1 to 2;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data s;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set sashelp.class;&lt;/SPAN&gt;&lt;BR /&gt;set sashelp.class;&lt;/P&gt;
&lt;P&gt;output;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Oct 2018 14:35:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/set-a-dataset-many-times-within-a-data-step/m-p/502124#M133997</guid>
      <dc:creator>ShufeGuoding</dc:creator>
      <dc:date>2018-10-06T14:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: set a dataset many times within a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/set-a-dataset-many-times-within-a-data-step/m-p/502125#M133998</link>
      <description>&lt;P&gt;the difference is as follows;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;105&amp;nbsp; data s;&lt;BR /&gt;106&amp;nbsp; do n=1 to 2;&lt;BR /&gt;107&amp;nbsp; set sashelp.class;&lt;BR /&gt;108&amp;nbsp; end;&lt;BR /&gt;109&amp;nbsp; run;&lt;/DIV&gt;&lt;DIV&gt;NOTE: There were 19 observations read from the data set SASHELP.CLASS.&lt;BR /&gt;NOTE: The data set WORK.S has 9 observations and 6 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.06 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;/DIV&gt;&lt;DIV&gt;&lt;BR /&gt;110&lt;BR /&gt;111&lt;BR /&gt;112&amp;nbsp; data s;&lt;BR /&gt;113&amp;nbsp; set sashelp.class;&lt;BR /&gt;114&amp;nbsp; set sashelp.class;&lt;BR /&gt;115&amp;nbsp; output;&lt;BR /&gt;116&amp;nbsp; run;&lt;/DIV&gt;&lt;DIV&gt;NOTE: There were 19 observations read from the data set SASHELP.CLASS.&lt;BR /&gt;NOTE: There were 19 observations read from the data set SASHELP.CLASS.&lt;BR /&gt;NOTE: The data set WORK.S has 19 observations and 5 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01 seconds&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;the second datastep may give you want you want but you did not describe your wants.&lt;/DIV&gt;&lt;DIV&gt;why are you assigning the same data table 2 times in the same datastep?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sat, 06 Oct 2018 14:42:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/set-a-dataset-many-times-within-a-data-step/m-p/502125#M133998</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-10-06T14:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: set a dataset many times within a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/set-a-dataset-many-times-within-a-data-step/m-p/502126#M133999</link>
      <description>&lt;P&gt;why?&lt;/P&gt;</description>
      <pubDate>Sat, 06 Oct 2018 14:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/set-a-dataset-many-times-within-a-data-step/m-p/502126#M133999</guid>
      <dc:creator>ShufeGuoding</dc:creator>
      <dc:date>2018-10-06T14:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: set a dataset many times within a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/set-a-dataset-many-times-within-a-data-step/m-p/502127#M134000</link>
      <description>&lt;P&gt;the why is because the code is incorrect.&lt;/P&gt;&lt;P&gt;do this if you want to dupe the table rows&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data s;
set sashelp.class sashelp.class;
output;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;117&lt;BR /&gt;118 data s;&lt;BR /&gt;119 set sashelp.class sashelp.class;&lt;BR /&gt;120 output;&lt;BR /&gt;121 run;&lt;/P&gt;&lt;P&gt;NOTE: There were 19 observations read from the data set SASHELP.CLASS.&lt;BR /&gt;NOTE: There were 19 observations read from the data set SASHELP.CLASS.&lt;BR /&gt;NOTE: The data set WORK.S has 38 observations and 5 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.06 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;try using /debug and you would see that in the first datastep the output is only done after exiting the do loop.&amp;nbsp; so you are getting records 2,4,6.....&lt;/P&gt;&lt;P&gt;in your second datastep you have to set statements.&amp;nbsp; the code here as set your_table your_table works based on your example.&amp;nbsp; The question is why do you want 2 rows with the same information in the same table?&lt;/P&gt;</description>
      <pubDate>Sat, 06 Oct 2018 14:56:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/set-a-dataset-many-times-within-a-data-step/m-p/502127#M134000</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-10-06T14:56:04Z</dc:date>
    </item>
    <item>
      <title>Re: set a dataset many times within a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/set-a-dataset-many-times-within-a-data-step/m-p/502129#M134002</link>
      <description>&lt;P&gt;The is because the sas compiler sets up one data stream for each instance of a SET statement.&amp;nbsp; In the first program there is one set statement, therefore one stream.&amp;nbsp; It's executed twice per each iteration of the data step, giving you observation numbers 2,4,6,8,10,12,14,16, and 18&amp;nbsp; (9 obs).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the second program there are two streams, each executed once per iteration of the data step.&amp;nbsp; In your example, in which both streams come from the same data source (and therefore have common variables), the second stream values overwrite the values obtained from the first stream.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, while two SET statements invoke two data streams, two INPUT statements read from the same raw data stream.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Oct 2018 14:51:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/set-a-dataset-many-times-within-a-data-step/m-p/502129#M134002</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-10-06T14:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: set a dataset many times within a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/set-a-dataset-many-times-within-a-data-step/m-p/502131#M134004</link>
      <description>&lt;P&gt;/debug can be of assistance when you have a why.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;step the records through the process and see what is happening by using the debugger.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data s / debug;
do n=1 to 2;
set sashelp.class;
end;
run;
 
 
data s / debug;
set sashelp.class;
set sashelp.class;
output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 06 Oct 2018 15:25:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/set-a-dataset-many-times-within-a-data-step/m-p/502131#M134004</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-10-06T15:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: set a dataset many times within a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/set-a-dataset-many-times-within-a-data-step/m-p/502175#M134022</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/22513"&gt;@ShufeGuoding&lt;/a&gt;: If you're not familiar with the data step debugger (and its somewhat cryptic commands),&amp;nbsp;here is a brief instruction:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/use-of-index/m-p/264460#M51865" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/use-of-index/m-p/264460#M51865&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Oct 2018 21:21:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/set-a-dataset-many-times-within-a-data-step/m-p/502175#M134022</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-06T21:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: set a dataset many times within a data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/set-a-dataset-many-times-within-a-data-step/m-p/502207#M134030</link>
      <description>&lt;P&gt;My intention is to understand the way in which&amp;nbsp; the data step read the obervations in input data set. I just wander why the&amp;nbsp; different obervations&amp;nbsp; are read&amp;nbsp; sequentially in the do loop in&amp;nbsp; one data step iteration in the first code , but it did not in the second code. Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Sun, 07 Oct 2018 00:55:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/set-a-dataset-many-times-within-a-data-step/m-p/502207#M134030</guid>
      <dc:creator>ShufeGuoding</dc:creator>
      <dc:date>2018-10-07T00:55:54Z</dc:date>
    </item>
  </channel>
</rss>

