<?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: The use of Output and Retain here? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/The-use-of-Output-and-Retain-here/m-p/254823#M48641</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1947"&gt;@Lulus﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is what happens&amp;nbsp;with&amp;nbsp;each observation of your example dataset when mohamed_zaki's data step is executed (focusing on the three lines of code starting with "&lt;FONT face="courier new,courier"&gt;if&lt;/FONT&gt;"):&lt;/P&gt;
&lt;PRE&gt;ID seq happen   comment
1   1    0      delflag is set to 0, obs. (incl. delflag) is written to WANT due to OUTPUT statement
1   2    0      delflag is still 0 due to RETAIN, obs. is written to WANT
1   3    1      delflag is still 0, obs. is written to WANT, delflag is set to 1
2   1    0      delflag is set to 0, obs. is written to WANT
2   2    1      delflag is still 0, obs. is written to WANT, delflag is set to 1
2   3    0      delflag is still 1, hence obs. is not written to WANT
2   4    1      delflag is still 1, hence obs. is not written to WANT, delflag is set to 1&lt;/PRE&gt;</description>
    <pubDate>Sun, 06 Mar 2016 11:08:07 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2016-03-06T11:08:07Z</dc:date>
    <item>
      <title>The use of Output and Retain here?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/The-use-of-Output-and-Retain-here/m-p/254817#M48637</link>
      <description>&lt;P&gt;&lt;SPAN class="login-bold"&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/delete-observation-based-on-previous-value/m-p/251441#M47507" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/delete-observation-based-on-previous-value/m-p/251441#M47507&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="login-bold"&gt;Please help with the following unanswered quesiton. &amp;nbsp;this is more programming quesiton. &amp;nbsp;thank you in advance your help!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="login-bold"&gt;follwing the quesiton from the URL,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="login-bold"&gt;however I have another silly question.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="  language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; delflag&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; output&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; happen&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; delflag&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in the above two statement,&lt;/P&gt;
&lt;P&gt;the lines with delflag=0 have been written to the want dataset and&lt;/P&gt;
&lt;P&gt;how does the next if clause still truncate the rest of observations against the same id?&lt;/P&gt;
&lt;P&gt;and even leave the first "happen=1" in the dataset?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to learn this logic. &amp;nbsp;your response is very appreicated.&lt;/P&gt;</description>
      <pubDate>Sun, 06 Mar 2016 10:17:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/The-use-of-Output-and-Retain-here/m-p/254817#M48637</guid>
      <dc:creator>Lulus</dc:creator>
      <dc:date>2016-03-06T10:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: The use of Output and Retain here?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/The-use-of-Output-and-Retain-here/m-p/254823#M48641</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1947"&gt;@Lulus﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is what happens&amp;nbsp;with&amp;nbsp;each observation of your example dataset when mohamed_zaki's data step is executed (focusing on the three lines of code starting with "&lt;FONT face="courier new,courier"&gt;if&lt;/FONT&gt;"):&lt;/P&gt;
&lt;PRE&gt;ID seq happen   comment
1   1    0      delflag is set to 0, obs. (incl. delflag) is written to WANT due to OUTPUT statement
1   2    0      delflag is still 0 due to RETAIN, obs. is written to WANT
1   3    1      delflag is still 0, obs. is written to WANT, delflag is set to 1
2   1    0      delflag is set to 0, obs. is written to WANT
2   2    1      delflag is still 0, obs. is written to WANT, delflag is set to 1
2   3    0      delflag is still 1, hence obs. is not written to WANT
2   4    1      delflag is still 1, hence obs. is not written to WANT, delflag is set to 1&lt;/PRE&gt;</description>
      <pubDate>Sun, 06 Mar 2016 11:08:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/The-use-of-Output-and-Retain-here/m-p/254823#M48641</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-03-06T11:08:07Z</dc:date>
    </item>
  </channel>
</rss>

