<?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: data step: comparing 1 record value with a previous record value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/data-step-comparing-1-record-value-with-a-previous-record-value/m-p/124697#M25529</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Art,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, you're right.&amp;nbsp; I didn't notice that EXIT appeared earlier on the list of BY variables.&amp;nbsp; Must be preoccupied with the thought of 12 guests coming for Thanksgiving!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 20 Nov 2012 19:51:37 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2012-11-20T19:51:37Z</dc:date>
    <item>
      <title>data step: comparing 1 record value with a previous record value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-step-comparing-1-record-value-with-a-previous-record-value/m-p/124691#M25523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;In a data set, I would like to compare a column value in one record with a column value in another record in the same data set (probably the previous record in the data set).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Nov 2012 14:33:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-step-comparing-1-record-value-with-a-previous-record-value/m-p/124691#M25523</guid>
      <dc:creator>Paul_NYS</dc:creator>
      <dc:date>2012-11-13T14:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: data step: comparing 1 record value with a previous record value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-step-comparing-1-record-value-with-a-previous-record-value/m-p/124692#M25524</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Paul: Question too vague.&amp;nbsp; Provide example data and desired result.&amp;nbsp; What is the maximum number of records that might separate the ones you want to compare?&amp;nbsp;&amp;nbsp; Are they within the same IDs?&amp;nbsp; What are the maximum number of records for an ID?&amp;nbsp;&amp;nbsp; And, do you need to use the value or just need to know if it was present?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BTW: You have a number of current threads that still appear as unanswered.&amp;nbsp; If they have been answered, please mark them accordingly so people don't spend unnecessary time trying to provide answers and solutions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Nov 2012 14:40:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-step-comparing-1-record-value-with-a-previous-record-value/m-p/124692#M25524</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-11-13T14:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: data step: comparing 1 record value with a previous record value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-step-comparing-1-record-value-with-a-previous-record-value/m-p/124693#M25525</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can do it by the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data s1AgeYear1CumPERM;&lt;/P&gt;&lt;P&gt;set s1AgeYear1PERM;&lt;/P&gt;&lt;P&gt;by cnty_name startyear exit agecat4 exitMonthCategory;&lt;/P&gt;&lt;P&gt;if exit ne "ZTC";&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if first.agecat4 then CumulativeNumber=0;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CumulativeNumber + COUNT;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Nov 2012 18:52:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-step-comparing-1-record-value-with-a-previous-record-value/m-p/124693#M25525</guid>
      <dc:creator>Paul_NYS</dc:creator>
      <dc:date>2012-11-20T18:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: data step: comparing 1 record value with a previous record value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-step-comparing-1-record-value-with-a-previous-record-value/m-p/124694#M25526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad to see that you were able to answer the question on your own.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Nov 2012 19:01:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-step-comparing-1-record-value-with-a-previous-record-value/m-p/124694#M25526</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-11-20T19:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: data step: comparing 1 record value with a previous record value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-step-comparing-1-record-value-with-a-previous-record-value/m-p/124695#M25527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Paul,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are two issues you will run into with this program. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. The subsetting IF statement may be deleting the first record for a group, the one where first.agecat4 is true.&amp;nbsp; In that case, your CumulativeNumber values will be thrown off.&amp;nbsp; At a minimum, you need to set CumulativeNumber to 0 BEFORE subsetting any observations.&amp;nbsp; Or, change IF to WHERE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. What if there are three or more observations in a BY group?&amp;nbsp; CumulativeNumber will be the sum of all COUNT values so far, for that BY group.&amp;nbsp; It's not the value from the previous observation.&lt;/P&gt;&lt;P&gt;It sounds like you have a lot of useful pieces there, but it doesn't sound like you have a final solution yet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Nov 2012 19:03:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-step-comparing-1-record-value-with-a-previous-record-value/m-p/124695#M25527</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-11-20T19:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: data step: comparing 1 record value with a previous record value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-step-comparing-1-record-value-with-a-previous-record-value/m-p/124696#M25528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="5253" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;: Actually, I think Paul accomplished what he wanted, using a different method, in a different thread.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, while I don't disagree with your recommendation to move the initialization up a line, I don't think that would pose a problem for him with the code he proposed.&amp;nbsp; His by statement was "&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;by cnty_name startyear exit agecat4 exitMonthCategory;&lt;/SPAN&gt;" and his statement referred to agecat4, thus all records with &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; exit eq "ZTC" would be deleted and his condition would still do what he wanted.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My only recommendation would be that he not rewrite the same file within the datastep, unless the exit eq "ZTC" records shouldn't exist in his data.&amp;nbsp; Obviously, after running the proposed code, they would no longer exist.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Nov 2012 19:32:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-step-comparing-1-record-value-with-a-previous-record-value/m-p/124696#M25528</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-11-20T19:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: data step: comparing 1 record value with a previous record value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-step-comparing-1-record-value-with-a-previous-record-value/m-p/124697#M25529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Art,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, you're right.&amp;nbsp; I didn't notice that EXIT appeared earlier on the list of BY variables.&amp;nbsp; Must be preoccupied with the thought of 12 guests coming for Thanksgiving!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Nov 2012 19:51:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-step-comparing-1-record-value-with-a-previous-record-value/m-p/124697#M25529</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-11-20T19:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: data step: comparing 1 record value with a previous record value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/data-step-comparing-1-record-value-with-a-previous-record-value/m-p/124698#M25530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hope that you and everyone has a nice thanksgiving.&amp;nbsp; We already celebrated Canadian thanksgiving, last month, but I'm trying to talk my wife into a second turkey.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Nov 2012 19:55:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/data-step-comparing-1-record-value-with-a-previous-record-value/m-p/124698#M25530</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-11-20T19:55:03Z</dc:date>
    </item>
  </channel>
</rss>

