<?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: Select most recent row with value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344833#M79280</link>
    <description>&lt;P&gt;Hi Ksharp,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have some questions regarding the understanding of your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when you write:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; if first.gvkey then call missing(of d{*},of i{*});
  
  do k=8 to 2 by -1;
   d{k}=d{k-1};
   i{k}=i{k-1};
  end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;From what I understand, whenever we encounter the first observation of a certain gvkey, you make all the values of the arrays to be missing, and then you make them all be the same - but they are already all missing in the first place?&lt;/P&gt;</description>
    <pubDate>Mon, 27 Mar 2017 23:48:28 GMT</pubDate>
    <dc:creator>ilikesas</dc:creator>
    <dc:date>2017-03-27T23:48:28Z</dc:date>
    <item>
      <title>Select most recent row with value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344281#M79110</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset with following variables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Gvkey = company identification code&lt;/P&gt;
&lt;P&gt;fyearq= fiscal year&lt;/P&gt;
&lt;P&gt;fqtr=fiscal quarter&lt;/P&gt;
&lt;P&gt;sale_dec= indicator value = 1 if sales decrease; else it is equals to 0&lt;/P&gt;
&lt;P&gt;saledec= value of decrease&lt;/P&gt;
&lt;P&gt;saleinc = value of increase&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to find:&lt;/P&gt;
&lt;P&gt;1. the most recent quarter with a sales decrease and its valueof decrease&lt;/P&gt;
&lt;P&gt;2. the most recent quarter with a sales increase and its value of increase&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for each fiscal year. The selection of the most recent quarter is based on the last 7 quarters (q-7) plus the current quarter (q).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you and hope to receive a solution soon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;mspak&lt;/P&gt;</description>
      <pubDate>Sat, 25 Mar 2017 10:31:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344281#M79110</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2017-03-25T10:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: Select most recent row with value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344287#M79112</link>
      <description>&lt;P&gt;Below should point you into the right direction.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname temp 'C:\temp';

proc sort data=temp.test out=inter;
  where sale_dec=1;
  by gvkey fyearq fqtr;
run;

/*the most recent quarter with a sales decrease and its valueof decrease per company identification code*/
data want1;
  set inter;
  by gvkey fyearq fqtr;
  if last.gvkey;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 Mar 2017 12:42:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344287#M79112</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-03-25T12:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: Select most recent row with value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344291#M79114</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/6107"&gt;@mspak&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;plz post your data at this forum, not XLS, ZIP file.&lt;/P&gt;
&lt;P&gt;No one would like to download these files from website due to virus risk.&lt;/P&gt;
&lt;P&gt;And do't forget to post the output you want see too.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is hard to understand what you mean by most recent quarter.&lt;/P&gt;
&lt;P&gt;Assuming I understand what you mean.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data last_decrease last_increase;
 do i=1 by 1 until(last.gvkey);
  set test;
  by gvkey;
  if sale_dec then idx_dec=i;
  if not missing(saleinc) then idx_inc=i;
 end;
 
 do j=1 by 1 until(last.gvkey);
  set test;
  by gvkey;
  if j=idx_dec then output last_decrease;
  if j=idx_inc then output last_increase;
 end;
 drop i j;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 Mar 2017 13:02:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344291#M79114</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-03-25T13:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: Select most recent row with value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344298#M79115</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The dataset is as follows:&lt;/P&gt;
&lt;P&gt;GVKEY &amp;nbsp;FYEARQ &amp;nbsp; FQTR &amp;nbsp; &amp;nbsp; &amp;nbsp; DATACQTR &amp;nbsp; &amp;nbsp;SALE_DEC &amp;nbsp; &amp;nbsp; SALEDEC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SALEINC&lt;/P&gt;
&lt;P&gt;001004 &amp;nbsp;2011 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2011Q3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4.0787026566 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;BR /&gt;001004 &amp;nbsp;2011 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2011Q4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;BR /&gt;001004 &amp;nbsp;2011 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2012Q1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-0.017301069&lt;BR /&gt;001004 &amp;nbsp;2011 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2012Q2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0.2664100989&lt;BR /&gt;001004 &amp;nbsp;2012 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2012Q3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1.8067205327 .&lt;BR /&gt;001004 &amp;nbsp;2012 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2012Q4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;BR /&gt;001004 &amp;nbsp;2012 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2013Q1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1.9264163544&lt;BR /&gt;001004 &amp;nbsp;2012 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2013Q2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-0.188650692&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With the above dataset, I would like to find the most recent quarter's sales decrease and most recent quarter's sales increase.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, the most recent quarter with a sales decrease for year 2011 and 2012 would be 4.01787...as this is the only sales decrease over the last 8 quarters.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The most recent sales increase for year 2011 would be&amp;nbsp;&lt;SPAN&gt;0.2664100989 as this is the latest value for sales increase over the last 8 quarters for year 2011. The value for the latest sales increase for 2012 would be -0.18865.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The most recent "sales decrease" event not neccessarily happen in the quarter 4 as the firm might experience the last "sales decrease" event during quarter 1 of previous year.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I wish the output as follows:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;GVKEY &amp;nbsp;FYEARQ &amp;nbsp; &amp;nbsp; SALEDEC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SALEINC&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;001004 &amp;nbsp; 2011 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4.0787026566 &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;0.2664100989&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;001004 &amp;nbsp; 2012 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4.0787026566 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; -0.188650692&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I hope that this make it clearer.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for any suggestions.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;MSPAK&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Mar 2017 14:29:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344298#M79115</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2017-03-25T14:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: Select most recent row with value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344383#M79137</link>
      <description>&lt;P&gt;OK. Mspak.&lt;/P&gt;
&lt;P&gt;So you want a rolling window which'length is eight quarter and output one obs for each id and year ?&lt;/P&gt;
&lt;P&gt;Assuming there is no gap(missing quarter in a year) in your data. Otherwise you need some more code to handle this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;


data want;
  set test;
  by GVKEY  FYEARQ;
  array d{8} _temporary_;
  array i{8} _temporary_;
  if first.gvkey then call missing(of d{*},of i{*});
  
  do k=8 to 2 by -1;
   d{k}=d{k-1};
   i{k}=i{k-1};
  end;
  
  d{1}=SALEDEC;
  i{1}=SALEINC;

  if last.fyearq then do; 
    last_decrease=coalesce(of d{*});
    last_increase=coalesce(of i{*});
    output;
  end;
 keep GVKEY  FYEARQ last_: ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Mar 2017 05:27:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344383#M79137</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-03-26T05:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: Select most recent row with value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344411#M79146</link>
      <description>&lt;P&gt;Thank you Ksharp for helps. This code is really useful. Have a nice day!&lt;/P&gt;</description>
      <pubDate>Sun, 26 Mar 2017 14:04:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344411#M79146</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2017-03-26T14:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: Select most recent row with value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344817#M79271</link>
      <description>&lt;P&gt;Hi mspak,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Very nice question, I am also working a lot with financial data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I looked at your data and noticed the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) saleinc has both positive and negative values - shouldn't they all be of the same sign?&lt;/P&gt;
&lt;P&gt;2) there are observations&amp;nbsp;when the sale_dec is either 0 or 1, but there is no value for the saledec or saleinc for these observations -is it because this information is missing in the original database?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 22:25:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344817#M79271</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2017-03-27T22:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: Select most recent row with value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344825#M79274</link>
      <description>The sale_dec is an indicator or dummy value, therefore it is either 1 0r 0.&lt;BR /&gt;The saledec or saleinc are logarithms transformation value, therefore, they&lt;BR /&gt;include both positive and negative values.&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Mon, 27 Mar 2017 23:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344825#M79274</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2017-03-27T23:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: Select most recent row with value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344833#M79280</link>
      <description>&lt;P&gt;Hi Ksharp,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have some questions regarding the understanding of your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when you write:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; if first.gvkey then call missing(of d{*},of i{*});
  
  do k=8 to 2 by -1;
   d{k}=d{k-1};
   i{k}=i{k-1};
  end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;From what I understand, whenever we encounter the first observation of a certain gvkey, you make all the values of the arrays to be missing, and then you make them all be the same - but they are already all missing in the first place?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 23:48:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344833#M79280</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2017-03-27T23:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: Select most recent row with value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344859#M79293</link>
      <description>&lt;PRE&gt;
Yes. they are all missing.
It doesn't matter. 
it is just one more useless operator for the first.gvkey.
it wouldn't change anything about result .


&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Mar 2017 03:23:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344859#M79293</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-03-28T03:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: Select most recent row with value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344878#M79302</link>
      <description>&lt;P&gt;Ok, but now I have another question!&lt;img id="smileyvery-happy" class="emoticon emoticon-smileyvery-happy" src="https://communities.sas.com/i/smilies/16x16_smiley-very-happy.png" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt;&lt;img id="smileytongue" class="emoticon emoticon-smileytongue" src="https://communities.sas.com/i/smilies/16x16_smiley-tongue.png" alt="Smiley Tongue" title="Smiley Tongue" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I realize that you are doing rolling windows, but can't understand it from the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So for a given observation, d{1} is the saledec for that period, and d{2} is the saledec for the previous perid etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But how do you put the saledec of the previous period into d{2}? You don't do something like d{2} = lag{saledec}, so how is it done?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2017 04:33:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344878#M79302</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2017-03-28T04:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: Select most recent row with value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344886#M79307</link>
      <description>&lt;P&gt;Yes. I do.&lt;/P&gt;
&lt;P&gt;The array D is temporary, which means it is retained during all the data step time.&lt;/P&gt;
&lt;P&gt;so when do&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt; do k&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;8&lt;/SPAN&gt; to &lt;SPAN class="token number"&gt;2&lt;/SPAN&gt; &lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;-1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   d&lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;k&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;d&lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;k&lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   i&lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;k&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;k&lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  end&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;assume &amp;nbsp;d{8}=1 2 3 4 5 6 7 8&lt;/P&gt;
&lt;P&gt;then the first time d{8}=current_obs 1 2 3 4 5 6 7&lt;/P&gt;
&lt;P&gt;&amp;nbsp;NOTE, 8 is removed from d{*}.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;next time when run&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt; d{8}=next_obs&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;current_obs 1 2 3 4 5 6&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;NOTE, 7 is removed from d{*}.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2017 05:36:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-most-recent-row-with-value/m-p/344886#M79307</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-03-28T05:36:53Z</dc:date>
    </item>
  </channel>
</rss>

