<?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 finding a specific value in a series of variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/finding-a-specific-value-in-a-series-of-variables/m-p/326740#M72822</link>
    <description>&lt;P&gt;Hi Experts,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset like below&lt;/P&gt;&lt;P&gt;DATA survey;&lt;BR /&gt;INPUT id r1 r2 r3 r4 r5;&lt;BR /&gt;DATALINES;&lt;BR /&gt;1 1 0 0 1 1&lt;BR /&gt;2 1 0 1 1 1&lt;BR /&gt;3 1 &amp;nbsp;. 0 . &amp;nbsp;1&lt;BR /&gt;4 1 1 0 1 1&lt;BR /&gt;5 0 1 . &amp;nbsp;.&amp;nbsp; 1&lt;BR /&gt;6 1 0 0 0 0&lt;BR /&gt;7 1 0 . &amp;nbsp;0&amp;nbsp;1&lt;BR /&gt;8 1 1 0 1 1&lt;/P&gt;&lt;P&gt;9 1 0 1 0 1&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to generate 2 new variables A=the variable name for the last observation of 0; B = the variable name for the first observation of 1 after the last 0. For example, the 6th row: A=r5, B=''; the 9th row: A=r4, B=r5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any idea how I can start? Thank you very much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 23 Jan 2017 15:22:31 GMT</pubDate>
    <dc:creator>sling</dc:creator>
    <dc:date>2017-01-23T15:22:31Z</dc:date>
    <item>
      <title>finding a specific value in a series of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-a-specific-value-in-a-series-of-variables/m-p/326740#M72822</link>
      <description>&lt;P&gt;Hi Experts,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset like below&lt;/P&gt;&lt;P&gt;DATA survey;&lt;BR /&gt;INPUT id r1 r2 r3 r4 r5;&lt;BR /&gt;DATALINES;&lt;BR /&gt;1 1 0 0 1 1&lt;BR /&gt;2 1 0 1 1 1&lt;BR /&gt;3 1 &amp;nbsp;. 0 . &amp;nbsp;1&lt;BR /&gt;4 1 1 0 1 1&lt;BR /&gt;5 0 1 . &amp;nbsp;.&amp;nbsp; 1&lt;BR /&gt;6 1 0 0 0 0&lt;BR /&gt;7 1 0 . &amp;nbsp;0&amp;nbsp;1&lt;BR /&gt;8 1 1 0 1 1&lt;/P&gt;&lt;P&gt;9 1 0 1 0 1&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to generate 2 new variables A=the variable name for the last observation of 0; B = the variable name for the first observation of 1 after the last 0. For example, the 6th row: A=r5, B=''; the 9th row: A=r4, B=r5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any idea how I can start? Thank you very much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 15:22:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-a-specific-value-in-a-series-of-variables/m-p/326740#M72822</guid>
      <dc:creator>sling</dc:creator>
      <dc:date>2017-01-23T15:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: finding a specific value in a series of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-a-specific-value-in-a-series-of-variables/m-p/326751#M72825</link>
      <description>&lt;P&gt;Since this sounds a lot like a "want to learn" I'm gong to provide some instructions not code&lt;/P&gt;
&lt;P&gt;Place the varaibles to search into an array&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Search the array from the largest index to the smallest: Hint: DIM and by -1. This will tell you where you find the 0. Then search from that position forward to find the 1, if any.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can get the name of an array member with the VNAME function.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2017 15:45:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-a-specific-value-in-a-series-of-variables/m-p/326751#M72825</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-23T15:45:37Z</dc:date>
    </item>
  </channel>
</rss>

