<?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: create trading days with sas function intnx in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-trading-days-with-sas-function-intnx/m-p/955273#M373088</link>
    <description>&lt;P&gt;Thank you! It works wonders!&lt;/P&gt;</description>
    <pubDate>Tue, 07 Jan 2025 04:00:13 GMT</pubDate>
    <dc:creator>Amelia6</dc:creator>
    <dc:date>2025-01-07T04:00:13Z</dc:date>
    <item>
      <title>create trading days with sas function intnx</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-trading-days-with-sas-function-intnx/m-p/955257#M373081</link>
      <description>&lt;P&gt;I'd like to create a date variable that is based on the number of trading days from an event date. For instance, the event date is 1/2/2024, I'd like to create a date for 100 trading days from 1/5/2025. Roughly speaking, trading days are week days plus the following holidays:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Third Monday of January — Martin Luther King Jr. Day&lt;/LI&gt;&lt;LI&gt;Third Monday of February — Presidents' Day&lt;/LI&gt;&lt;LI&gt;Last Monday of May — Memorial Day&lt;/LI&gt;&lt;LI&gt;June 19 — Juneteenth&lt;/LI&gt;&lt;LI&gt;July 4 — Independence Day&lt;/LI&gt;&lt;LI&gt;First Monday of September — Labor Day&lt;/LI&gt;&lt;LI&gt;Fourth Thursday of November— Thanksgiving Day&lt;/LI&gt;&lt;LI&gt;Dec. 25 — Christmas Day&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I understand I can do newdate=intnx('weekdays',olddate,100) to count only week days. But how can I also account for(exclude) the above holidays? Thank you! Attached is sample of data with old dates that I'd like to calculate the new dates on. Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2025 22:54:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-trading-days-with-sas-function-intnx/m-p/955257#M373081</guid>
      <dc:creator>Amelia6</dc:creator>
      <dc:date>2025-01-06T22:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: create trading days with sas function intnx</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-trading-days-with-sas-function-intnx/m-p/955270#M373085</link>
      <description>&lt;P&gt;You can just count:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set raw.dates;

  _count_=0;
  do _n_=1 to 200 until(_count_=100);
    newdate=olddate+_n_;
    _year_=year(newdate);

    if not(
       weekday(newdate) in (1 7) /*Saturday,Sunday*/
       or newdate=holiday('mlk',_year_)
       or newdate=holiday('uspresidents',_year_)
       or newdate=holiday('memorial',_year_)
       or newdate=holiday('juneteenth',_year_)
       or newdate=holiday('usindependence',_year_)
       or newdate=holiday('labor',_year_)
       or newdate=holiday('thanksgiving',_year_)
       or newdate=holiday('christmas',_year_)
    ) then _count_+1;
  end;

  put olddate=  newdate= yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Jan 2025 02:37:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-trading-days-with-sas-function-intnx/m-p/955270#M373085</guid>
      <dc:creator>whymath</dc:creator>
      <dc:date>2025-01-07T02:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: create trading days with sas function intnx</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-trading-days-with-sas-function-intnx/m-p/955271#M373086</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname x v9 'c:\temp';
data want;
 set x.dates;
 array x{8};
 count=0;
 do newdate=olddate to '1jan2050'd;
/*  x1=holiday('MLK', year(newdate));*/
  x1=nwkdom(3,2,1, year(newdate));   /*Third Monday of January — Martin Luther King Jr. Day*/
  x2=nwkdom(3,2,2, year(newdate));  /*Third Monday of February — Presidents' Day*/
  x3=nwkdom(5,2,5, year(newdate));  /*Last Monday of May — Memorial Day*/
  x4=mdy(6,19, year(newdate));  /*June 19 — Juneteenth*/
  x5=mdy(7,4, year(newdate));  /*July 4 — Independence Day*/
  x6=nwkdom(1,2,9, year(newdate));  /*First Monday of September — Labor Day*/
  x7=nwkdom(4,5,11, year(newdate));  /*Fourth Thursday of November— Thanksgiving Day*/
  x8=mdy(12,25, year(newdate));  /*Dec. 25 — Christmas Day*/


  if weekday(newdate) not in (1 7) and newdate not in x then count+1;
  if count=100 then leave;
 end;
 format newdate x: yymmdd10.;
 drop count;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Jan 2025 02:50:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-trading-days-with-sas-function-intnx/m-p/955271#M373086</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-01-07T02:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: create trading days with sas function intnx</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-trading-days-with-sas-function-intnx/m-p/955272#M373087</link>
      <description>&lt;P&gt;Thank you! It works beautifully!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2025 03:59:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-trading-days-with-sas-function-intnx/m-p/955272#M373087</guid>
      <dc:creator>Amelia6</dc:creator>
      <dc:date>2025-01-07T03:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: create trading days with sas function intnx</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-trading-days-with-sas-function-intnx/m-p/955273#M373088</link>
      <description>&lt;P&gt;Thank you! It works wonders!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2025 04:00:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-trading-days-with-sas-function-intnx/m-p/955273#M373088</guid>
      <dc:creator>Amelia6</dc:creator>
      <dc:date>2025-01-07T04:00:13Z</dc:date>
    </item>
  </channel>
</rss>

