<?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: Getting data from previous rows to categorise with a Hierarchy in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Getting-data-from-previous-rows-to-categorise-with-a-Hierarchy/m-p/213355#M39409</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is a kind of "cumulative minimum" problem (for each group):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set OriginOfPorblems;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by Nmr;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain HighestCategory;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.Nmr then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; HighestCategory=.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; HighestCategory=min(input(Category,3.), HighestCategory);&amp;nbsp; /*Converting to number, and taking the cmulative minimum*/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 May 2015 12:41:19 GMT</pubDate>
    <dc:creator>gergely_batho</dc:creator>
    <dc:date>2015-05-12T12:41:19Z</dc:date>
    <item>
      <title>Getting data from previous rows to categorise with a Hierarchy</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-data-from-previous-rows-to-categorise-with-a-Hierarchy/m-p/213354#M39408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good morning from Holland,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will be the first time asking a question concerning sas. I've only been using SAS EG for a short period of time, getting pretty used to the drag and drop part of it. But I need to get in to data steps more and more. I've been struggling with this problem for quite a bit.&lt;/P&gt;&lt;P&gt;I'll try to explain the question first. Hope I picked a decent title and put the topic in the right area. (Hardest thing of asking a question is coming up with a good title &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Question:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;In my dataset I have Clients (Nmr) that have different "problems" that occur in our system handling these clients (conflicting data or business rules) that need intensive handlabor to fix. What i want to do is find out what kind of problems occur and where they lead.&lt;/P&gt;&lt;P&gt;So i've categorised the sorts of problems with a number (category) 1 beeing the biggest problem and a higher number indicates smaller problems (the hierarchy). The records are sorted on the date the problem occured.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What i want to do is analyse the clients and see what route the problems take (taking a hierarchy into acocunt) so when a client has a problem category 10 on date 1 i want it to show 10.. on date 2 the client has a problem category 6 i want it to show 6, but when on date 3 the client has another problem category 10 i want it to keep showing 6 until a higher ranked problem occurs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've been trying some stuf with LAGs with some IF's and I have been trying to do some loops (most of them infinity :smileysilly:) which did not gave me the result I wanted. In the data set below i have 4 collumns. I can't solve it with a few consecutive LAG's because that could mean looking back 100 rows which is quite common.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Collumn 1 (Nmr)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = The client number&lt;/P&gt;&lt;P&gt;Collumn 2 (Category)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = The category number 1 beeing highest ranked&lt;/P&gt;&lt;P&gt;Collumn 3 (Date)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = Date in DDMMYY&lt;/P&gt;&lt;P&gt;Collumn 4 (WantedResults)&amp;nbsp;&amp;nbsp; = The results i would like for these 2 test records&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Data Set:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data OriginOfPorblems;&lt;/P&gt;&lt;P&gt;input Nmr $ Category $ Date : anydtdte9. WantedResults;&lt;/P&gt;&lt;P&gt;format Date ddmmyy10.;&lt;/P&gt;&lt;P&gt;return;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 14 1-2-2014 14&lt;/P&gt;&lt;P&gt;1 14 9-2-2014 14&lt;/P&gt;&lt;P&gt;1 7 4-3-2014 7&lt;/P&gt;&lt;P&gt;1 3 4-4-2014 3&lt;/P&gt;&lt;P&gt;1 3 22-5-2014 3&lt;/P&gt;&lt;P&gt;1 14 20-6-2014 3&lt;/P&gt;&lt;P&gt;1 13 12-12-2014 3&lt;/P&gt;&lt;P&gt;2 13 14-3-2014 3&lt;/P&gt;&lt;P&gt;2 13 14-3-2014 13&lt;/P&gt;&lt;P&gt;2 13 14-3-2014 13&lt;/P&gt;&lt;P&gt;2 13 14-3-2014 13&lt;/P&gt;&lt;P&gt;2 13 17-3-2014 13&lt;/P&gt;&lt;P&gt;2 13 17-3-2014 13&lt;/P&gt;&lt;P&gt;2 10 24-9-2014 10&lt;/P&gt;&lt;P&gt;2 13 5-11-2014 10&lt;/P&gt;&lt;P&gt;2 15 5-11-2014 10&lt;/P&gt;&lt;P&gt;2 13 11-11-2014 10&lt;/P&gt;&lt;P&gt;2 16 24-11-2014 10&lt;/P&gt;&lt;P&gt;2 7 2-12-2014 7&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bit of a long Post but I hope i've been able to adress my issue in an understandable fassion. If there are any pointers or if I did something terribly wrong asking the question, feedback is welcome &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for the responses,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheer,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Frank&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 May 2015 08:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-data-from-previous-rows-to-categorise-with-a-Hierarchy/m-p/213354#M39408</guid>
      <dc:creator>FrankvP</dc:creator>
      <dc:date>2015-05-12T08:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: Getting data from previous rows to categorise with a Hierarchy</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-data-from-previous-rows-to-categorise-with-a-Hierarchy/m-p/213355#M39409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is a kind of "cumulative minimum" problem (for each group):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set OriginOfPorblems;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by Nmr;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain HighestCategory;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.Nmr then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; HighestCategory=.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; HighestCategory=min(input(Category,3.), HighestCategory);&amp;nbsp; /*Converting to number, and taking the cmulative minimum*/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 May 2015 12:41:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-data-from-previous-rows-to-categorise-with-a-Hierarchy/m-p/213355#M39409</guid>
      <dc:creator>gergely_batho</dc:creator>
      <dc:date>2015-05-12T12:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: Getting data from previous rows to categorise with a Hierarchy</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-data-from-previous-rows-to-categorise-with-a-Hierarchy/m-p/213356#M39410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks so much! Exactly what I was looking for!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 May 2015 13:12:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-data-from-previous-rows-to-categorise-with-a-Hierarchy/m-p/213356#M39410</guid>
      <dc:creator>FrankvP</dc:creator>
      <dc:date>2015-05-12T13:12:01Z</dc:date>
    </item>
  </channel>
</rss>

