<?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: output observation at each change of occurance for 0, 1 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/output-observation-at-each-change-of-occurance-for-0-1/m-p/573354#M161862</link>
    <description>&lt;P&gt;If data sorted by subject variable :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA WANT (drop=x);
SET HAVE;
BY SUBJECT;
X=IFN(RESPONSE EQ LAG(Response),0,1);
IF X;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 14 Jul 2019 08:39:09 GMT</pubDate>
    <dc:creator>singhsahab</dc:creator>
    <dc:date>2019-07-14T08:39:09Z</dc:date>
    <item>
      <title>output observation at each change of occurance for 0, 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/output-observation-at-each-change-of-occurance-for-0-1/m-p/573313#M161835</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I have a data set with coded values 0 and 1 that are sorted by subject and&amp;nbsp;date.&amp;nbsp; Each time the occurrence happens, coded 1.&amp;nbsp; When stops, coded 0.&amp;nbsp; If occurrence happens again, then 1&amp;nbsp; etc.&amp;nbsp; I want to output the&amp;nbsp;observation by subject at each change of occurrence&amp;nbsp;&amp;nbsp;(1, 0, back to 1 etc).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas how I can set this up?&lt;/P&gt;
&lt;P&gt;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&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;125&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;1-Dec-18&lt;/TD&gt;
&lt;TD&gt;X&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;125&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;20-Dec-18&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Sat, 13 Jul 2019 20:01:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/output-observation-at-each-change-of-occurance-for-0-1/m-p/573313#M161835</guid>
      <dc:creator>jenim514</dc:creator>
      <dc:date>2019-07-13T20:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: output observation at each change of occurance for 0, 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/output-observation-at-each-change-of-occurance-for-0-1/m-p/573314#M161836</link>
      <description>&lt;P&gt;Use the NOTSORTED keyword on your BY statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have;
  by subject response notsorted;
  if first.response;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 Jul 2019 20:03:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/output-observation-at-each-change-of-occurance-for-0-1/m-p/573314#M161836</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-13T20:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: output observation at each change of occurance for 0, 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/output-observation-at-each-change-of-occurance-for-0-1/m-p/573354#M161862</link>
      <description>&lt;P&gt;If data sorted by subject variable :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA WANT (drop=x);
SET HAVE;
BY SUBJECT;
X=IFN(RESPONSE EQ LAG(Response),0,1);
IF X;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jul 2019 08:39:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/output-observation-at-each-change-of-occurance-for-0-1/m-p/573354#M161862</guid>
      <dc:creator>singhsahab</dc:creator>
      <dc:date>2019-07-14T08:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: output observation at each change of occurance for 0, 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/output-observation-at-each-change-of-occurance-for-0-1/m-p/573373#M161873</link>
      <description>&lt;P&gt;That will not work if two adjacent subjects happen to have the same value of RESPONSE.&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jul 2019 14:36:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/output-observation-at-each-change-of-occurance-for-0-1/m-p/573373#M161873</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-14T14:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: output observation at each change of occurance for 0, 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/output-observation-at-each-change-of-occurance-for-0-1/m-p/573586#M161965</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; thank you!</description>
      <pubDate>Mon, 15 Jul 2019 16:30:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/output-observation-at-each-change-of-occurance-for-0-1/m-p/573586#M161965</guid>
      <dc:creator>jenim514</dc:creator>
      <dc:date>2019-07-15T16:30:03Z</dc:date>
    </item>
  </channel>
</rss>

