<?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 create id from a sorted visit frequency data in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/create-id-from-a-sorted-visit-frequency-data/m-p/234808#M5941</link>
    <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If i have a data which is the following&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data t;INPUT x;&lt;/P&gt;
&lt;P&gt;cards;&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This data set is&amp;nbsp;merged from each person.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, its id should be 1 1 2 2 2 3 3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How could I get the the id I want? I have tried use the if first statement, but I failed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please tell me the easiest way to do it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 15 Nov 2015 15:58:04 GMT</pubDate>
    <dc:creator>ffgsdf</dc:creator>
    <dc:date>2015-11-15T15:58:04Z</dc:date>
    <item>
      <title>create id from a sorted visit frequency data</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/create-id-from-a-sorted-visit-frequency-data/m-p/234808#M5941</link>
      <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If i have a data which is the following&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data t;INPUT x;&lt;/P&gt;
&lt;P&gt;cards;&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This data set is&amp;nbsp;merged from each person.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, its id should be 1 1 2 2 2 3 3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How could I get the the id I want? I have tried use the if first statement, but I failed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please tell me the easiest way to do it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Nov 2015 15:58:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/create-id-from-a-sorted-visit-frequency-data/m-p/234808#M5941</guid>
      <dc:creator>ffgsdf</dc:creator>
      <dc:date>2015-11-15T15:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: create id from a sorted visit frequency data</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/create-id-from-a-sorted-visit-frequency-data/m-p/234811#M5942</link>
      <description>&lt;P&gt;This would be one way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;priorx = lag(x);&lt;/P&gt;
&lt;P&gt;if _n_=1 or x &amp;lt;= priorx then id + 1;&lt;/P&gt;
&lt;P&gt;drop priorx;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This assumes that when X stays the same from one observation to the next, that the ID should be different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Nov 2015 16:58:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/create-id-from-a-sorted-visit-frequency-data/m-p/234811#M5942</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-11-15T16:58:15Z</dc:date>
    </item>
  </channel>
</rss>

