<?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: Identify last trading days in each year from 1998 to 2017 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identify-last-trading-days-in-each-year-from-1998-to-2017/m-p/439983#M109834</link>
    <description>&lt;P&gt;1. Sort your data set descending so that you can take the first 5 of each group.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Use a counter variable to take the first five records.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;You can create the counters as illustrated here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stats.idre.ucla.edu/sas/faq/how-can-i-create-an-enumeration-variable-by-groups/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/faq/how-can-i-create-an-enumeration-variable-by-groups/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: Note that this assumes you have a single record for each date, if you don't the answer is different, but the link above illustrates how to count with multiple variables in your BY group.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2018-02-24 at 2.30.40 PM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18799i51425975A3675D3E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2018-02-24 at 2.30.40 PM.png" alt="Screen Shot 2018-02-24 at 2.30.40 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/143540"&gt;@nazmul&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Hello Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to keep the last 5 trading day data in each year from 1998 to 2017. &amp;nbsp;I am using daily VIX data series from Yahoo Finance. I downloaded the data from the following link. Could you please help me in doing the job in SAS?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://finance.yahoo.com/quote/%5EVIX/history?period1=1298523600&amp;amp;period2=1519448400&amp;amp;interval=1d&amp;amp;filter=history&amp;amp;frequency=1d" target="_blank"&gt;https://finance.yahoo.com/quote/%5EVIX/history?period1=1298523600&amp;amp;period2=1519448400&amp;amp;interval=1d&amp;amp;filter=history&amp;amp;frequency=1d&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 24 Feb 2018 21:35:35 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-02-24T21:35:35Z</dc:date>
    <item>
      <title>Identify last trading days in each year from 1998 to 2017</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-last-trading-days-in-each-year-from-1998-to-2017/m-p/439967#M109829</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Hello Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to keep the last 5 trading day data in each year from 1998 to 2017. &amp;nbsp;I am using daily VIX data series from Yahoo Finance. I downloaded the data from the following link. Could you please help me in doing the job in SAS?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://finance.yahoo.com/quote/%5EVIX/history?period1=1298523600&amp;amp;period2=1519448400&amp;amp;interval=1d&amp;amp;filter=history&amp;amp;frequency=1d" target="_blank"&gt;https://finance.yahoo.com/quote/%5EVIX/history?period1=1298523600&amp;amp;period2=1519448400&amp;amp;interval=1d&amp;amp;filter=history&amp;amp;frequency=1d&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Feb 2018 20:25:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-last-trading-days-in-each-year-from-1998-to-2017/m-p/439967#M109829</guid>
      <dc:creator>nazmul</dc:creator>
      <dc:date>2018-02-24T20:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: Identify last trading days in each year from 1998 to 2017 [how to improve your question]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-last-trading-days-in-each-year-from-1998-to-2017/m-p/439969#M109831</link>
      <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/143540"&gt;@nazmul&lt;/a&gt;,&lt;/P&gt;&lt;BR /&gt; &lt;P&gt;Your question requires more details before experts can help.&amp;nbsp;Can you revise your question to include more information?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Review this checklist:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Specify a meaningful subject line for your topic.&amp;nbsp; Avoid generic subjects like "need help," "SAS query," or "urgent."&lt;/LI&gt;
&lt;LI&gt;When appropriate, provide sample data in text or DATA step format.&amp;nbsp; See &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;this article for one method&lt;/A&gt;&amp;nbsp;you can use.&lt;/LI&gt;
&lt;LI&gt;If you're encountering an error in SAS, include the SAS log or a screenshot of the error condition.&amp;nbsp;Use the&amp;nbsp;&lt;STRONG&gt;Photos&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;button to include the image in your message.&lt;BR /&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" style="width: 279px;"&gt;&lt;IMG src="https://kntur85557.i.lithium.com/t5/image/serverpage/image-id/16608i91A52F817EAC9A69/image-dimensions/279x150?v=1.0" width="279" height="150" alt="use_buttons.png" title="use_buttons.png" /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;It also helps to include an example (table or picture) of the result that you're trying to achieve.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;To edit your original message, select the "blue gear" icon at the top of the message and select&amp;nbsp;&lt;STRONG&gt;Edit Message&lt;/STRONG&gt;.&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;From there you can adjust the title and add more details to the body of the message.&amp;nbsp; Or, simply reply to this message with any additional information you can supply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" style="width: 229px;"&gt;&lt;IMG src="https://kntur85557.i.lithium.com/t5/image/serverpage/image-id/16605iAC020BC79315B045/image-size/large?v=1.0&amp;amp;px=600" alt="edit_post.png" title="edit_post.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;SAS experts are eager to help -- help&amp;nbsp;&lt;EM&gt;them&lt;/EM&gt; by providing as much detail as you can.&lt;/P&gt; &lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-style:italic;font-size:smaller;"&gt;This prewritten response was triggered for you by fellow SAS Support Communities member &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&lt;/SPAN&gt;&lt;/P&gt;.</description>
      <pubDate>Sat, 24 Feb 2018 20:07:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-last-trading-days-in-each-year-from-1998-to-2017/m-p/439969#M109831</guid>
      <dc:creator>Community_Guide</dc:creator>
      <dc:date>2018-02-24T20:07:53Z</dc:date>
    </item>
    <item>
      <title>Re: Identify last trading days in each year from 1998 to 2017 [how to improve your question]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-last-trading-days-in-each-year-from-1998-to-2017/m-p/439970#M109832</link>
      <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/143540"&gt;@nazmul&lt;/a&gt;,&lt;/P&gt;&lt;BR /&gt; &lt;P&gt;Your question requires more details before experts can help.&amp;nbsp;Can you revise your question to include more information?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Review this checklist:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Specify a meaningful subject line for your topic.&amp;nbsp; Avoid generic subjects like "need help," "SAS query," or "urgent."&lt;/LI&gt;
&lt;LI&gt;When appropriate, provide sample data in text or DATA step format.&amp;nbsp; See &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;this article for one method&lt;/A&gt;&amp;nbsp;you can use.&lt;/LI&gt;
&lt;LI&gt;If you're encountering an error in SAS, include the SAS log or a screenshot of the error condition.&amp;nbsp;Use the&amp;nbsp;&lt;STRONG&gt;Photos&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;button to include the image in your message.&lt;BR /&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" style="width: 279px;"&gt;&lt;IMG src="https://kntur85557.i.lithium.com/t5/image/serverpage/image-id/16608i91A52F817EAC9A69/image-dimensions/279x150?v=1.0" width="279" height="150" alt="use_buttons.png" title="use_buttons.png" /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;It also helps to include an example (table or picture) of the result that you're trying to achieve.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;To edit your original message, select the "blue gear" icon at the top of the message and select&amp;nbsp;&lt;STRONG&gt;Edit Message&lt;/STRONG&gt;.&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;From there you can adjust the title and add more details to the body of the message.&amp;nbsp; Or, simply reply to this message with any additional information you can supply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" style="width: 229px;"&gt;&lt;IMG src="https://kntur85557.i.lithium.com/t5/image/serverpage/image-id/16605iAC020BC79315B045/image-size/large?v=1.0&amp;amp;px=600" alt="edit_post.png" title="edit_post.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;SAS experts are eager to help -- help&amp;nbsp;&lt;EM&gt;them&lt;/EM&gt; by providing as much detail as you can.&lt;/P&gt; &lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-style:italic;font-size:smaller;"&gt;This prewritten response was triggered for you by fellow SAS Support Communities member &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&lt;/SPAN&gt;&lt;/P&gt;.</description>
      <pubDate>Sat, 24 Feb 2018 20:07:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-last-trading-days-in-each-year-from-1998-to-2017/m-p/439970#M109832</guid>
      <dc:creator>Community_Guide</dc:creator>
      <dc:date>2018-02-24T20:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: Identify last trading days in each year from 1998 to 2017</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-last-trading-days-in-each-year-from-1998-to-2017/m-p/439983#M109834</link>
      <description>&lt;P&gt;1. Sort your data set descending so that you can take the first 5 of each group.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Use a counter variable to take the first five records.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;You can create the counters as illustrated here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stats.idre.ucla.edu/sas/faq/how-can-i-create-an-enumeration-variable-by-groups/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/faq/how-can-i-create-an-enumeration-variable-by-groups/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: Note that this assumes you have a single record for each date, if you don't the answer is different, but the link above illustrates how to count with multiple variables in your BY group.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2018-02-24 at 2.30.40 PM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18799i51425975A3675D3E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2018-02-24 at 2.30.40 PM.png" alt="Screen Shot 2018-02-24 at 2.30.40 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/143540"&gt;@nazmul&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Hello Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to keep the last 5 trading day data in each year from 1998 to 2017. &amp;nbsp;I am using daily VIX data series from Yahoo Finance. I downloaded the data from the following link. Could you please help me in doing the job in SAS?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://finance.yahoo.com/quote/%5EVIX/history?period1=1298523600&amp;amp;period2=1519448400&amp;amp;interval=1d&amp;amp;filter=history&amp;amp;frequency=1d" target="_blank"&gt;https://finance.yahoo.com/quote/%5EVIX/history?period1=1298523600&amp;amp;period2=1519448400&amp;amp;interval=1d&amp;amp;filter=history&amp;amp;frequency=1d&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Feb 2018 21:35:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-last-trading-days-in-each-year-from-1998-to-2017/m-p/439983#M109834</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-24T21:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: Identify last trading days in each year from 1998 to 2017</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-last-trading-days-in-each-year-from-1998-to-2017/m-p/439984#M109835</link>
      <description>Thank you so much!</description>
      <pubDate>Sat, 24 Feb 2018 21:43:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-last-trading-days-in-each-year-from-1998-to-2017/m-p/439984#M109835</guid>
      <dc:creator>nazmul</dc:creator>
      <dc:date>2018-02-24T21:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: Identify last trading days in each year from 1998 to 2017</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-last-trading-days-in-each-year-from-1998-to-2017/m-p/439997#M109837</link>
      <description>&lt;P&gt;If the data are already sorted by stock, and ascending date, the descending sort can be an expensive solution, compared to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop=_:);
  merge have (firstobs=1)
        have (firstobs=6 keep=stock rename=(stock=_stock5));
  if stock^=_stock5;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just look ahead 5 observations to see whether the look-ahead stock (_stock5) is the same as the current stock.&amp;nbsp; The "firstobs=1" parameter is the default value, but I put it in there to draw attention to what is actually happening.&amp;nbsp; Two data streams (offset by 5 observations) are being read synchronously.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Feb 2018 01:39:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-last-trading-days-in-each-year-from-1998-to-2017/m-p/439997#M109837</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-02-25T01:39:21Z</dc:date>
    </item>
  </channel>
</rss>

