<?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: Adding ID field based on another varible that includes missing values in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Adding-ID-field-based-on-another-varible-that-includes-missing/m-p/190728#M48063</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually its the fact that the the first one is a value that makes my logic unclear.&amp;nbsp; How do you know the first one and 20 are the same?&amp;nbsp; Where does the extra missing come from the last series of 20's?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This seems a bit contrived, and not sure it will actually handle your data. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;retain contentid 1 last;&lt;/P&gt;&lt;P&gt;if col1 ne . then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if col1 ne last and last ne . then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; contentid+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; last=col1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if col1 ne last then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; last=col1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end; &lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Feb 2014 15:48:40 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2014-02-28T15:48:40Z</dc:date>
    <item>
      <title>Adding ID field based on another varible that includes missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-ID-field-based-on-another-varible-that-includes-missing/m-p/190727#M48062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a data table that has rows that I want to give a number too based on a variable.&amp;nbsp; For example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following data:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;col1&lt;/P&gt;&lt;P&gt;------------&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;20&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;20&lt;/P&gt;&lt;P&gt;20&lt;/P&gt;&lt;P&gt;20&lt;/P&gt;&lt;P&gt;20&lt;/P&gt;&lt;P&gt;20&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to create another variable called contentid.&amp;nbsp; The data should be like this&lt;/P&gt;&lt;P&gt;col1&amp;nbsp;&amp;nbsp; contentid&lt;/P&gt;&lt;P&gt;------------&lt;/P&gt;&lt;P&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;20&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;&lt;P&gt;6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;&lt;P&gt;6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;&lt;P&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;&lt;P&gt;20&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;20&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;20&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;20&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;20&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've used a data step with a retain statement but i'm not sure at what point to increment&amp;nbsp; the value of contentid.&amp;nbsp; The fact there is missing rows is causing me the hardest time.&lt;/P&gt;&lt;P&gt;This is what I have so far&lt;/P&gt;&lt;P&gt;data test ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length contentid $2 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set x ;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; retain contentid ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_ = 1 then contentid = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for any help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Feb 2014 15:25:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-ID-field-based-on-another-varible-that-includes-missing/m-p/190727#M48062</guid>
      <dc:creator>jerry898969</dc:creator>
      <dc:date>2014-02-28T15:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: Adding ID field based on another varible that includes missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-ID-field-based-on-another-varible-that-includes-missing/m-p/190728#M48063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually its the fact that the the first one is a value that makes my logic unclear.&amp;nbsp; How do you know the first one and 20 are the same?&amp;nbsp; Where does the extra missing come from the last series of 20's?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This seems a bit contrived, and not sure it will actually handle your data. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;retain contentid 1 last;&lt;/P&gt;&lt;P&gt;if col1 ne . then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if col1 ne last and last ne . then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; contentid+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; last=col1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if col1 ne last then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; last=col1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end; &lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Feb 2014 15:48:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-ID-field-based-on-another-varible-that-includes-missing/m-p/190728#M48063</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-02-28T15:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: Adding ID field based on another varible that includes missing values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Adding-ID-field-based-on-another-varible-that-includes-missing/m-p/190729#M48064</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the reply.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is data coming from a data set someone else sends me.&amp;nbsp;&amp;nbsp; It's the back end data file for a front end that shows data based on the content id.&amp;nbsp; The missing will generate a space when the user views the application.&amp;nbsp; That data was just an example of how the data could come to me and I have to tag the rows with the correct content id.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That code worked for the example data I'm using.&amp;nbsp; I will run it against the full data set when it is sent to me. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Feb 2014 15:55:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Adding-ID-field-based-on-another-varible-that-includes-missing/m-p/190729#M48064</guid>
      <dc:creator>jerry898969</dc:creator>
      <dc:date>2014-02-28T15:55:01Z</dc:date>
    </item>
  </channel>
</rss>

