<?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: Can we find the next value of a longitudinal dataset is different from the previous value? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Can-we-find-the-next-value-of-a-longitudinal-dataset-is/m-p/102710#M28756</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi mkeintz,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is a great explanation! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you indeed for your time and sharing your expertise.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think I have very very long way to go.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mirisage&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 26 Aug 2012 15:14:22 GMT</pubDate>
    <dc:creator>Mirisage</dc:creator>
    <dc:date>2012-08-26T15:14:22Z</dc:date>
    <item>
      <title>Can we find the next value of a longitudinal dataset is different from the previous value?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Can-we-find-the-next-value-of-a-longitudinal-dataset-is/m-p/102706#M28752</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;Hi Colleagues,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Attached data set (post_this2) shows 3 different accounts in 3 different banks.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;When the bank_number,&amp;nbsp; account_number and current_date are taken together only we can identify a unique record. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: fuchsia; font-size: 10pt; text-decoration: underline;"&gt;Q:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Is there any method that we could identify what are the accounts that still have a life even after they have fallen into “writoff’ arrears_band.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: fuchsia; font-size: 10pt; text-decoration: underline;"&gt;Answer:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Account_number ‘&lt;/SPAN&gt;&lt;SPAN style="font-family: Arial; color: black; font-size: 10pt;"&gt;888888888’ in bank_number 100 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial; background: yellow; color: black; font-size: 10pt;"&gt;(because this AC has fallen into &lt;/SPAN&gt;&lt;SPAN style="background: yellow; color: black; font-size: 10pt;"&gt;“writoff’ arrears_band in 3JUN2011 and it again starts its life and continues for another period)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-family: Arial; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Also, Account_number ‘&lt;/SPAN&gt;&lt;SPAN style="font-family: Arial; color: black; font-size: 10pt;"&gt;888888888’ in bank_number 40&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial; background: yellow; color: black; font-size: 10pt;"&gt;(Because this AC has fallen into &lt;/SPAN&gt;&lt;SPAN style="background: yellow; font-size: 10pt;"&gt;“writoff’ arrears_band in 28MAR2011 and it again its life and continues for several months)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Arial; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Your help is greately apprecaited.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Mirisage &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Aug 2012 18:39:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Can-we-find-the-next-value-of-a-longitudinal-dataset-is/m-p/102706#M28752</guid>
      <dc:creator>Mirisage</dc:creator>
      <dc:date>2012-08-23T18:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: Can we find the next value of a longitudinal dataset is different from the previous value?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Can-we-find-the-next-value-of-a-longitudinal-dataset-is/m-p/102707#M28753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mirisage:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you saying bank 100 account 888888888 has life after 03jun2011, even though the only record after that date also has arrear_bands='writoff'?&amp;nbsp;&amp;nbsp; If so, then you are saying you want all accounts in which the first "writoff" record encountered does not end the time series.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (keep=bank_number account_number);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by bank_number account_number notsorted;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain writoff_encountered 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.account_number then writoff_encountered=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last.account_number and writoff_encountered=1 then output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if arrears_bank='writoff' then writoff_encountered=1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;**this program assumes that records are sorted by date&amp;nbsp; within each banki/account group (which themselve might not be sorted).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Aug 2012 18:58:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Can-we-find-the-next-value-of-a-longitudinal-dataset-is/m-p/102707#M28753</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2012-08-23T18:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: Can we find the next value of a longitudinal dataset is different from the previous value?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Can-we-find-the-next-value-of-a-longitudinal-dataset-is/m-p/102708#M28754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi mkeintz,&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN style="font-family: Verdana;"&gt;Thank you very much for this code which ideally selects the subjects that &lt;/SPAN&gt;&lt;SPAN lang="EN" style="font-family: Verdana; color: black;"&gt;satisfy my condition &lt;STRONG&gt;“I &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN" style="font-family: Verdana; color: #575757;"&gt;want all accounts in which the first "writoff" record encountered does not end the time series”.&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN lang="EN" style="font-family: Verdana; color: #575757;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN lang="EN" style="font-family: Verdana; color: #575757;"&gt;( Last statement’s arrears_ban&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN" style="font-family: Verdana; color: fuchsia;"&gt;k &lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN" style="font-family: Verdana; color: #575757;"&gt;should be read as&amp;nbsp;&amp;nbsp; arrears_ban&lt;/SPAN&gt;&lt;SPAN lang="EN" style="font-family: Verdana; color: fuchsia;"&gt;d &lt;/SPAN&gt;&lt;SPAN lang="EN" style="font-family: Verdana; color: #575757;"&gt;&amp;nbsp; )&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN lang="EN" style="font-family: Verdana; color: #575757;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN lang="EN" style="font-family: Verdana; color: #575757;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN lang="EN" style="font-family: Verdana; background: yellow; color: #575757;"&gt;If you have time, could you please elaborate a bit what this magic code does?&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN lang="EN" style="font-family: Verdana; color: #575757;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN lang="EN" style="font-family: Verdana; color: blue;"&gt;I can understand that you have done a “by group processing” which is done by “set” and “by” combination. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN lang="EN" style="font-family: Verdana; color: blue;"&gt;Also can understand when SAS finds the&amp;nbsp; first.account_number then it creates a variable called writoff_encountered and its value is set to 0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN lang="EN" style="font-family: Verdana; color: #575757;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN lang="EN" style="font-family: Verdana; color: #575757;"&gt;And when SAS finds the&amp;nbsp; last.account_number then the created&amp;nbsp; variable “writoff_encountered”’s&amp;nbsp; value is set to 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN lang="EN" style="font-family: Verdana; color: #575757;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN lang="EN" style="font-family: Verdana; color: #993366;"&gt;But how the rest is happening to satisfy my condition. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN lang="EN" style="font-family: Verdana; color: #575757;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN lang="EN" style="font-family: Verdana; color: #575757;"&gt;What does “not sorted” do ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 0px 0.5in;"&gt;&lt;SPAN lang="EN" style="font-family: Verdana; color: #575757;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Thank you&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Mirisage&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2012 18:43:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Can-we-find-the-next-value-of-a-longitudinal-dataset-is/m-p/102708#M28754</guid>
      <dc:creator>Mirisage</dc:creator>
      <dc:date>2012-08-24T18:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: Can we find the next value of a longitudinal dataset is different from the previous value?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Can-we-find-the-next-value-of-a-longitudinal-dataset-is/m-p/102709#M28755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mirisage:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The "not sorted" parameter of the BY statement tells SAS to not expect the data to be in ascending order, but still to expect the data to be "grouped".&amp;nbsp; So you could have bank 2/acct2, then bank1/acct4, then bank 5/acct3 and SAS would not object.&amp;nbsp; It would still determine the "first." and "last." variables at the beginning and ending of each group.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However "not sorted" also means SAS will also not care if the records for a given bank/acct are not in chronological order.&amp;nbsp; That's why I said the program assumes that, within each bank/acct, the records are in date order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As to how the rest works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; RETAIN writoff_encountered 0;&amp;nbsp; &lt;BR /&gt;means SAS will not reset this new variable to a missing value at the top of the data set.&amp;nbsp; It will keep whatever value it already has.&amp;nbsp; The "0" means to start out with a zero - this aspect was superfluous.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At the beginning of a bank/acct group set this dummy var to zero.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now "if arrears_bank-..." means upon such a record set the dummy to 1.&amp;nbsp; It will stay a 1 throughout the bank/acct group (the retain statement).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now consider if a bank/acct had only 1 "writoff" record and it was the last record.&amp;nbsp; In this case you would not want an output record.&amp;nbsp; But if I had put the "if last.account and writoff_encountered-1 then output"&amp;nbsp; AFTER the "if arrears_bank='writoff" record, then that last record would have been output, counter to your request.&amp;nbsp; So I put the "if .... output .." statement BEFORE checking for "writoff'.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 26 Aug 2012 02:26:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Can-we-find-the-next-value-of-a-longitudinal-dataset-is/m-p/102709#M28755</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2012-08-26T02:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: Can we find the next value of a longitudinal dataset is different from the previous value?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Can-we-find-the-next-value-of-a-longitudinal-dataset-is/m-p/102710#M28756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi mkeintz,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is a great explanation! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you indeed for your time and sharing your expertise.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think I have very very long way to go.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mirisage&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 26 Aug 2012 15:14:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Can-we-find-the-next-value-of-a-longitudinal-dataset-is/m-p/102710#M28756</guid>
      <dc:creator>Mirisage</dc:creator>
      <dc:date>2012-08-26T15:14:22Z</dc:date>
    </item>
  </channel>
</rss>

