<?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 Matching CRSP Daily with non-trading days in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Matching-CRSP-Daily-with-non-trading-days/m-p/574031#M162121</link>
    <description>&lt;P&gt;Hi All...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have asked similar questions but cannot get the right answer yet. I thought I got the answer... but realized it is not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CRSP Daily data only has trading dates( no holidays, no Saturdays, No Sundays).&lt;/P&gt;&lt;P&gt;I have other data(let me call it OTHER) that has just random calendar dates.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I want to merge these two, I inevitably lose some non-trading days that are in OTHER.&lt;/P&gt;&lt;P&gt;Rather losing OTHER's date, I want to keep them by matching the closest trading dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, 2019/07/14 (it is Sunday) will be matched with 2019/07/15.&lt;/P&gt;&lt;P&gt;In other words, I do not want to lose any data in OTHER because of not matching dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone know this kind of code that matched the closet available date?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tons of Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jerry&lt;/P&gt;</description>
    <pubDate>Tue, 16 Jul 2019 22:08:09 GMT</pubDate>
    <dc:creator>JKCho</dc:creator>
    <dc:date>2019-07-16T22:08:09Z</dc:date>
    <item>
      <title>Matching CRSP Daily with non-trading days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-CRSP-Daily-with-non-trading-days/m-p/574031#M162121</link>
      <description>&lt;P&gt;Hi All...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have asked similar questions but cannot get the right answer yet. I thought I got the answer... but realized it is not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CRSP Daily data only has trading dates( no holidays, no Saturdays, No Sundays).&lt;/P&gt;&lt;P&gt;I have other data(let me call it OTHER) that has just random calendar dates.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I want to merge these two, I inevitably lose some non-trading days that are in OTHER.&lt;/P&gt;&lt;P&gt;Rather losing OTHER's date, I want to keep them by matching the closest trading dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, 2019/07/14 (it is Sunday) will be matched with 2019/07/15.&lt;/P&gt;&lt;P&gt;In other words, I do not want to lose any data in OTHER because of not matching dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone know this kind of code that matched the closet available date?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tons of Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jerry&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2019 22:08:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-CRSP-Daily-with-non-trading-days/m-p/574031#M162121</guid>
      <dc:creator>JKCho</dc:creator>
      <dc:date>2019-07-16T22:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: Matching CRSP Daily with non-trading days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-CRSP-Daily-with-non-trading-days/m-p/574032#M162122</link>
      <description>&lt;P&gt;Example input data for BOTH data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example of the desired result for those data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Include at least one example of each type of match involved&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions here: &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;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2019 22:11:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-CRSP-Daily-with-non-trading-days/m-p/574032#M162122</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-07-16T22:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: Matching CRSP Daily with non-trading days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-CRSP-Daily-with-non-trading-days/m-p/574054#M162130</link>
      <description>&lt;P&gt;This means you'll have duplicates from CRSP when they match equal OTHER date and they match closest OTHER date.&lt;/P&gt;
&lt;P&gt;Is this what you want?&lt;/P&gt;
&lt;P&gt;If you have two possible closest matches (day before and day after), what do you do?&lt;/P&gt;
&lt;P&gt;In other words and as stated, please provide usable examples.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 01:42:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-CRSP-Daily-with-non-trading-days/m-p/574054#M162130</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-07-17T01:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: Matching CRSP Monthly with non-trading days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-CRSP-Daily-with-non-trading-days/m-p/574229#M162216</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table esgprice37 as
select a.* , b.*
from CRSPnew a
inner join esgtest4 b
on a.cusip = b.cusip8 and b.DATADATE13 - a.DATE &amp;gt;=0
having (b.DATADATE37 - a.DATE)=min(b.DATADATE37 - a.DATE);
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;oh... my bad.&lt;/P&gt;&lt;P&gt;I need the closest&amp;nbsp;'next' day.&lt;/P&gt;&lt;P&gt;I will provide examples.&amp;nbsp;&lt;/P&gt;&lt;P&gt;By the way, using the above code only provided outcomes that two dates are exactly matched (datadate37=date).&lt;/P&gt;&lt;P&gt;For example, when the DATADATE37 is 2012/03/28, my code does not match this date with 2012/03/31 from CRSP Monthly(I use monthly data now for convenience. the data I attach is also monthly data).&lt;/P&gt;&lt;P&gt;Rather, my code deletes all kinds of this unmatched dates and output the exactly matched dates only... (DATADATE37 = date).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The intention of the code below is not to delete unmatched data. But my outcome is not like that.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;having (b.DATADATE37 - a.DATE)=min(b.DATADATE37 - a.DATE);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please have a look on my data files and try the first above code and please look through the outcome. The output data missed almost half of the original observations. I referred to other posts in the community and the WRDS's article. BUT theire codes are the same as mine I used.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 15:36:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-CRSP-Daily-with-non-trading-days/m-p/574229#M162216</guid>
      <dc:creator>JKCho</dc:creator>
      <dc:date>2019-07-17T15:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Matching CRSP Monthly with non-trading days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-CRSP-Daily-with-non-trading-days/m-p/574230#M162217</link>
      <description>&lt;P&gt;Yes. The CRSP file is too big to upload. Let me make a very simplified file&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 15:38:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-CRSP-Daily-with-non-trading-days/m-p/574230#M162217</guid>
      <dc:creator>JKCho</dc:creator>
      <dc:date>2019-07-17T15:38:23Z</dc:date>
    </item>
    <item>
      <title>Re: Matching CRSP Daily with non-trading days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-CRSP-Daily-with-non-trading-days/m-p/574263#M162234</link>
      <description>&lt;P&gt;I attach very simply files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want is... just as below.&amp;nbsp; Because of the discrepancy between Trading and Calender day, I used the code&amp;nbsp;&lt;/P&gt;&lt;P&gt;"having (a.DATE - b.d_9 )=min(a.DATE - b.d_9 );"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code is not working somehow...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&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="1.PNG" style="width: 776px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31092i05E57CE8EDA96E2E/image-dimensions/776x379?v=v2" width="776" height="379" role="button" title="1.PNG" alt="1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 16:21:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-CRSP-Daily-with-non-trading-days/m-p/574263#M162234</guid>
      <dc:creator>JKCho</dc:creator>
      <dc:date>2019-07-17T16:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: Matching CRSP Daily with non-trading days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-CRSP-Daily-with-non-trading-days/m-p/574274#M162238</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Enterprise-Guide/The-execution-of-this-query-involves-performing-one-or-more/td-p/443275" target="_blank"&gt;https://communities.sas.com/t5/SAS-Enterprise-Guide/The-execution-of-this-query-involves-performing-one-or-more/td-p/443275&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To all(specifically SAS Rookies like me),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the problem that I lost the output is due to missing Group by~~~.&lt;/P&gt;&lt;P&gt;Plz, refer to the above link if you lose the output observations and have NOTE like Cartesian products blah blah~~&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 16:47:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-CRSP-Daily-with-non-trading-days/m-p/574274#M162238</guid>
      <dc:creator>JKCho</dc:creator>
      <dc:date>2019-07-17T16:47:19Z</dc:date>
    </item>
  </channel>
</rss>

