<?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 Phasing across Variables Issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Phasing-across-Variables-Issue/m-p/198935#M37270</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;Hi&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;I have a issue that I am currently trying to solve, however I have not been having much luck on google or forum searches&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;I have a situation where I need to calculate the worst status a customer has filed in 12 months - I have 96 months of data - 1 month = 1 variable so I have 96 variables&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My issue arrises where customers can begin and end at different points - I need to find a function or macro where I can scan across the variables to find the most recent month a customer filed a status, and then do a IF MAX calculation from that point&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because customers begin and end at different points I am finding this quite difficult to master and was wondering if anyone had any previous experience or insight?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have included a simplified example below where I have been testing based on worst status in last 3 months&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If anyone has any advice I would really appreciate it&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;DATA e&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;xample;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;input &lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;cust_no mon1 mon2 mon3 mon4 mon5 mon6;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;DATALINES;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;1001 0 0 1 1 . .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;1002 . . 0 0 4 4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;1003 0 0 0 0 0 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;1004 . 1 2 3 4 .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Mar 2015 12:28:57 GMT</pubDate>
    <dc:creator>t_kingsbury</dc:creator>
    <dc:date>2015-03-11T12:28:57Z</dc:date>
    <item>
      <title>Phasing across Variables Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Phasing-across-Variables-Issue/m-p/198935#M37270</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;Hi&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;I have a issue that I am currently trying to solve, however I have not been having much luck on google or forum searches&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;I have a situation where I need to calculate the worst status a customer has filed in 12 months - I have 96 months of data - 1 month = 1 variable so I have 96 variables&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My issue arrises where customers can begin and end at different points - I need to find a function or macro where I can scan across the variables to find the most recent month a customer filed a status, and then do a IF MAX calculation from that point&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because customers begin and end at different points I am finding this quite difficult to master and was wondering if anyone had any previous experience or insight?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have included a simplified example below where I have been testing based on worst status in last 3 months&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If anyone has any advice I would really appreciate it&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;DATA e&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;xample;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;input &lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;cust_no mon1 mon2 mon3 mon4 mon5 mon6;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;DATALINES;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;1001 0 0 1 1 . .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;1002 . . 0 0 4 4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;1003 0 0 0 0 0 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;1004 . 1 2 3 4 .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="font-size-2" style="font-family: arial,helvetica,sans-serif;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Mar 2015 12:28:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Phasing-across-Variables-Issue/m-p/198935#M37270</guid>
      <dc:creator>t_kingsbury</dc:creator>
      <dc:date>2015-03-11T12:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: Phasing across Variables Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Phasing-across-Variables-Issue/m-p/198936#M37271</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Set up an array for the months:&lt;/P&gt;&lt;P&gt;array months {} mon1-mon96;&lt;/P&gt;&lt;P&gt;now you can iterate through that with months{x}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cust_start = 0;&lt;/P&gt;&lt;P&gt;cust_end = 0;&lt;/P&gt;&lt;P&gt;cust_max = 0;&lt;/P&gt;&lt;P&gt;do i = 1 to 96;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if months{i} ne .&lt;/P&gt;&lt;P&gt;&amp;nbsp; then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if cust_start = 0 then cust_start = i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cust_max = max(cust_max,months{i});&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else if cust_start ne 0 then cust_end = i - 1;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;should give you starting and ending month for a customer and the maximum value encountered&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Mar 2015 12:45:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Phasing-across-Variables-Issue/m-p/198936#M37271</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-03-11T12:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: Phasing across Variables Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Phasing-across-Variables-Issue/m-p/198937#M37272</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am kinda slow on following your description. What will be the most recent month, the month1 or month96? What do mean by file a status, anything greater than 0? What's your definition by bad/worse/worst, is it higher the number, the worse the case? And What the outcome you are expecting given your presented data?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Mar 2015 13:05:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Phasing-across-Variables-Issue/m-p/198937#M37272</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-03-11T13:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: Phasing across Variables Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Phasing-across-Variables-Issue/m-p/198938#M37273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hai,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I appreciate that my explanation could have been clearer, my apologies&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The most recent month would be month96 - the window is a 96 month period (last 8 years)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for the status, the status is defined anything not missing, in the case of my example 0,1,2,3 and 4 are statuses so 4 is the worst&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The outcome I am looking for is to be able to calculate the max value, a defined number of periods back based on the last status filed - so in my example if you take customer 1002 - that customer is present in four periods, I would like to be able to find the last period that customer filed a status in, and then find the max value in the last 3 periods (the answer would be 4)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using shortened numbers in my example data to simplify the scenario&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Mar 2015 14:29:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Phasing-across-Variables-Issue/m-p/198938#M37273</guid>
      <dc:creator>t_kingsbury</dc:creator>
      <dc:date>2015-03-11T14:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: Phasing across Variables Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Phasing-across-Variables-Issue/m-p/198939#M37274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In that case, you'd be better off in going through the array backwards from the end, register when the first non-missing column shows up, and then take the max for the next 4(3) iterations.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Mar 2015 14:44:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Phasing-across-Variables-Issue/m-p/198939#M37274</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-03-11T14:44:24Z</dc:date>
    </item>
  </channel>
</rss>

