<?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: Trying to use first. and last. processing in 3rd variable of a by statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-first-and-last-processing-in-3rd-variable-of-a-by/m-p/142852#M28594</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks alot&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Dec 2014 16:32:42 GMT</pubDate>
    <dc:creator>Xamius32</dc:creator>
    <dc:date>2014-12-09T16:32:42Z</dc:date>
    <item>
      <title>Trying to use first. and last. processing in 3rd variable of a by statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-first-and-last-processing-in-3rd-variable-of-a-by/m-p/142849#M28591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For example, I am trying to see how often variable Z changes in the X group&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;X&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Y&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Z&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;201401&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;600&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;201402&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;600&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;201403&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;750&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Variable X is in this example a particular loan, with Y being the monthend and Z being the score.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So lets say there are 10 identical Zs in a row and then the 11th observation is a different Z for the same X, I want to know that there were 10 in a row before changing. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I realize first.Z would be 1 for each Z because Y changes each observation (sorted by X Y Z). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can get Z to add up correctly when I say if lag(Z)=Z then variable AA+1, but then I dont know how to output only the observation when AA changes back to one (when Z would have a new observation). Again, I cant use last. processing because Y changes each time, and we want the data in the order of Y. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for any help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 16:10:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-first-and-last-processing-in-3rd-variable-of-a-by/m-p/142849#M28591</guid>
      <dc:creator>Xamius32</dc:creator>
      <dc:date>2014-12-09T16:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use first. and last. processing in 3rd variable of a by statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-first-and-last-processing-in-3rd-variable-of-a-by/m-p/142850#M28592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try it with the notsorted option? I'm not 100% sure what type of output you want so you can try it with the last. here and see if that provides what you need.&lt;/P&gt;&lt;P&gt;&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;by x z notsorted;&lt;/P&gt;&lt;P&gt;if first.z then count=1; else count+1;&lt;/P&gt;&lt;P&gt;if last.z then output; *not sure this is what you want;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 16:17:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-first-and-last-processing-in-3rd-variable-of-a-by/m-p/142850#M28592</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-12-09T16:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use first. and last. processing in 3rd variable of a by statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-first-and-last-processing-in-3rd-variable-of-a-by/m-p/142851#M28593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Similar to &lt;A __default_attr="255172" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;'s suggested code but, if you want AA to reflect the same count for all records having the same value of z within an x, then a double dow would do that kind of task:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do until (last.z);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by x z notsorted;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if first.z then AA=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else AA+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do until (last.z);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; by x z notsorted;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 16:27:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-first-and-last-processing-in-3rd-variable-of-a-by/m-p/142851#M28593</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-12-09T16:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to use first. and last. processing in 3rd variable of a by statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-first-and-last-processing-in-3rd-variable-of-a-by/m-p/142852#M28594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks alot&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 16:32:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-use-first-and-last-processing-in-3rd-variable-of-a-by/m-p/142852#M28594</guid>
      <dc:creator>Xamius32</dc:creator>
      <dc:date>2014-12-09T16:32:42Z</dc:date>
    </item>
  </channel>
</rss>

