<?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: Merging two datasets by permno and date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-permno-and-date/m-p/421453#M280802</link>
    <description>&lt;P&gt;Please supply example data. Use the macro from&amp;nbsp;&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; to convert subsets of data to datasteps, and post them here according to &lt;A href="https://communities.sas.com/t5/help/faqpage/faq-category-id/posting?nobounce" target="_blank"&gt;https://communities.sas.com/t5/help/faqpage/faq-category-id/posting?nobounce&lt;/A&gt;. Also supply an example of the expected result. If you already have code that you tried, include that also.&lt;/P&gt;</description>
    <pubDate>Fri, 15 Dec 2017 08:35:55 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-12-15T08:35:55Z</dc:date>
    <item>
      <title>Merging two datasets by permno and date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-permno-and-date/m-p/421451#M280801</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to merge a dataset which includes CRSP + IBES data with another IPO data set. The first datasets includes e.g. permno, ncusip, date, stock returns. However it has 50million rows since it includes daily stock returns. The other dataset includes only 7000 IPOs including PERMNO, NCUSIP, dates etc). I would like to merge these two data sets so that in the end I have a set where there is only those original 7000 IPOs + correct stock return from the first day of the IPO. What kind of code should I use to merge these two sets by the date and some identifier (e.g. permno)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Voutsu&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2017 08:18:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-permno-and-date/m-p/421451#M280801</guid>
      <dc:creator>Voutsu</dc:creator>
      <dc:date>2017-12-15T08:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets by permno and date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-permno-and-date/m-p/421453#M280802</link>
      <description>&lt;P&gt;Please supply example data. Use the macro from&amp;nbsp;&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; to convert subsets of data to datasteps, and post them here according to &lt;A href="https://communities.sas.com/t5/help/faqpage/faq-category-id/posting?nobounce" target="_blank"&gt;https://communities.sas.com/t5/help/faqpage/faq-category-id/posting?nobounce&lt;/A&gt;. Also supply an example of the expected result. If you already have code that you tried, include that also.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2017 08:35:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-permno-and-date/m-p/421453#M280802</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-12-15T08:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets by permno and date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-permno-and-date/m-p/421465#M280803</link>
      <description>&lt;P&gt;Alright, thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not using University Edition so is there also instructions for 9.4 version?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2017 09:26:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-permno-and-date/m-p/421465#M280803</guid>
      <dc:creator>Voutsu</dc:creator>
      <dc:date>2017-12-15T09:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets by permno and date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-permno-and-date/m-p/421469#M280804</link>
      <description>&lt;P&gt;The macro is included in the download as a .sas file. Store that anywhere on your PC, and either open it with EG or the enhanced editor of Base SAS, or with a text editor and copy/paste the text to SAS Studio. Once you run the code, the macro is ready for use. The macro code itself contains a description of it's use in a section that is also written to the log when the macro is used with !HELP as a parameter.&lt;/P&gt;
&lt;P&gt;If you want to use the macro repeatedly in the future, you can include it in your autocall library.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2017 09:53:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-permno-and-date/m-p/421469#M280804</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-12-15T09:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets by permno and date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-permno-and-date/m-p/421586#M280805</link>
      <description>&lt;P&gt;Without data set names or variables it is very hard to be very specific. What it sounds like is you might be looking for some sort of Proc SQL left join&lt;/P&gt;
&lt;P&gt;here is a skeleton&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table want as
   select a.permno, a.ncusip, a.dateofselection, &amp;lt;repeat for other variables you want 
      from the set aliased as a&amp;gt;, b.var1, b.var2, &amp;lt;repeat for other variables wanted&amp;gt;
   from smallerdataset as a
        left join
        otherdataset  as b
        on a.permno=b.permno
        and a.ncusip=b.ncusip
        and a.dateofselection=b.dateofselection
        &amp;lt;repeat for other matching criteria&amp;gt;
   ;
quit;&lt;/PRE&gt;
&lt;P&gt;you would want enough variables in the ON matches to reduce your matches from the larger dataset to a single record. If the variables have different names but the same values then use the matching variables. Note that the above comparisons assume that the case and spelling is the same (IBM will not match I.B.M. or GENERAL ELECTRIC will not match General Electric).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2017 15:03:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-permno-and-date/m-p/421586#M280805</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-12-15T15:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets by permno and date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-permno-and-date/m-p/421670#M280806</link>
      <description>&lt;P&gt;Since you've merged CRSP and IBES data, I bet your dataset (call it CRSP_IBES) is already sorted by permno/date.&amp;nbsp; If so, this is almost surely the fastest way to extract CRSP_IBES data for just the permno/dates of interest (from dataset we'll call IPODATA):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=ipodata out=temp;
  by permno date;
run;

data want;
  merge crsp_ibes  temp (in=int);
  by permno date;
  if int;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Question:&amp;nbsp; Since&amp;nbsp;you are using public trade-exchange data as reported by CRSP, presumably the earliest record in CRSP_IBES for each PERMNO is an IPO date (or it's a date for new permnos from companies merging, splitting, or issuing new share classes).&amp;nbsp; So I would assume that the permno/dates in IPO_DATA is a proper subset of the collection of earliest records for each permno in CRSP_IBES.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If for any permno, you find that is not the case, (i.e. crsp_ibes has dates preceding the ipo date), you should investigate those permno's.&amp;nbsp; This assumes, of course, that the date in IPO_DATA is the IPO date related to the company issuing the stock identified by PERMNO.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2017 18:32:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-permno-and-date/m-p/421670#M280806</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-12-15T18:32:50Z</dc:date>
    </item>
  </channel>
</rss>

