<?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: Matching data (ID and date) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Matching-data-ID-and-date/m-p/572187#M161461</link>
    <description>&lt;P&gt;well.. I am actually working on a massive data set but I am too clumsy. I have utilized my codes on the internet but all was not the answer...&lt;/P&gt;&lt;P&gt;maybe it is better to post a new post and attach my code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you:)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 09 Jul 2019 18:40:39 GMT</pubDate>
    <dc:creator>JKCho</dc:creator>
    <dc:date>2019-07-09T18:40:39Z</dc:date>
    <item>
      <title>Matching data (ID and date)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-data-ID-and-date/m-p/571671#M161282</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a new SAS learner and particularly having difficulties in matching multiple datasets. Many classes have taught me various regression analysis but mana trimming...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want to do is...&lt;/P&gt;&lt;P&gt;I have two data files. there is a variable in common so that I can match these two files by this variable. However, my date files are panel data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example,&lt;/P&gt;&lt;P&gt;Data1&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; Data2&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Date(Daily)&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;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Date(Monthly)&lt;/P&gt;&lt;P&gt;1000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;09/09/2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1000&amp;nbsp; &amp;nbsp; &amp;nbsp; 08/10/2000&lt;/P&gt;&lt;P&gt;1000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;09/10/2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1000&amp;nbsp; &amp;nbsp; &amp;nbsp; 09/10/2000&lt;/P&gt;&lt;P&gt;1000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;09/11/2000&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;2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; as same as others...&lt;/P&gt;&lt;P&gt;and so on.... for ID 1000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;and so on....&lt;/P&gt;&lt;P&gt;2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;09/01/2000&lt;/P&gt;&lt;P&gt;2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;same as above&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;same as above&amp;nbsp;&lt;/P&gt;&lt;P&gt;and so on.... for ID 2000&lt;/P&gt;&lt;P&gt;3000&lt;/P&gt;&lt;P&gt;and so on....&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want to have is... to match by ID as below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MatchedData&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Date(Daily)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Date(Monthly)&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;1000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;09/09/2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.(missing data)&lt;/P&gt;&lt;P&gt;1000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;09/10/2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;09/10/2000&lt;/P&gt;&lt;P&gt;1000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;09/11/2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.(missing data)&lt;/P&gt;&lt;P&gt;2000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Like the above...&lt;/P&gt;&lt;P&gt;3000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I used many-to-many merge, this code created a huge data whose date numbers are Date(daily) multiplied by Date(Monthly).&lt;/P&gt;&lt;P&gt;This is not a thing I wish to have but I merely want to know the code for matching.&lt;/P&gt;&lt;P&gt;To say simple, &lt;U&gt;&lt;U&gt;I want to match both&lt;/U&gt;&lt;STRONG&gt; ID &lt;/STRONG&gt;and&lt;STRONG&gt; date.&lt;/STRONG&gt;&lt;/U&gt; What is demanding is there might be no available matching ID, date or both. For example, there is ID 1111 in data1 but not in data2, or ID 1111 with date 09/01/2000 but not exactly the same in data2. At this stage, I rather let them be; all unmatch rows are retained.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please please PLEASE share your wisdom!! I know it is kind of easy but for me so demanding...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also... if you are generous enough, please help me once again.&lt;/P&gt;&lt;P&gt;I have other data that are time series and want to combine these by 'year'.&lt;/P&gt;&lt;P&gt;One is yearly data and another is Monthly.&lt;/P&gt;&lt;P&gt;What I want to have is...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Matched&lt;/P&gt;&lt;P&gt;Variable1(from Monthly) Variable2(from yearly)&amp;nbsp; &amp;nbsp; Monthly&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yearly&lt;/P&gt;&lt;P&gt;0000&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; aaaa&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; 10/01/2000&amp;nbsp; &amp;nbsp; &amp;nbsp; 2000&lt;/P&gt;&lt;P&gt;0000&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; aaaa&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; 11/01/2000&amp;nbsp; &amp;nbsp; &amp;nbsp; 2000&lt;/P&gt;&lt;P&gt;0000&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;aaaa&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; 12/01/2000&amp;nbsp; &amp;nbsp; &amp;nbsp; 2000&lt;/P&gt;&lt;P&gt;0000&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; bbbb&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; 01/01/2001&amp;nbsp; &amp;nbsp; &amp;nbsp; 2001&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since Variable2 are from Yearly data, there should be many duplicates in Matched and that is what I want. As I need to match by using different variables I do not even know how to start.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate your time on my questions and thank you for your help very much!!!!&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jul 2019 21:47:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-data-ID-and-date/m-p/571671#M161282</guid>
      <dc:creator>JKCho</dc:creator>
      <dc:date>2019-07-07T21:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: Matching data (ID and date)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-data-ID-and-date/m-p/571675#M161283</link>
      <description>&lt;P&gt;Welcome the the SAS community!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Please provide your data in the form of a data step (and check that the pasted code runs properly) when asking questions, like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DATA_D ;
  input ID DATE : ddmmyy10.; 
  format DATE ddmmyy10.;
cards;
1000 09/09/2000                     
1000 09/10/2000                     
1000 09/11/2000                     
run;

data DATA_M;
  input ID DATE ddmmyy10.; 
  format DATE ddmmyy10.;
cards; 
1000 08/10/2000
1000 09/10/2000
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2. This should do what you need:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WANT;
  merge DATA_D (in=D)
        DATA_M (in=M);
  by ID DATE;
  if D then DATE_D=DATE;
  if M then DATE_M=DATE;
  drop DATE;
  format DATE_D DATE_M ddmmyy10.;
run;

proc print noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;ID&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;DATE_D&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;DATE_M&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1000&lt;/TD&gt;
&lt;TD class="r data"&gt;09/09/2000&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1000&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;08/10/2000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1000&lt;/TD&gt;
&lt;TD class="r data"&gt;09/10/2000&lt;/TD&gt;
&lt;TD class="r data"&gt;09/10/2000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1000&lt;/TD&gt;
&lt;TD class="r data"&gt;09/11/2000&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jul 2019 22:42:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-data-ID-and-date/m-p/571675#M161283</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-07-07T22:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: Matching data (ID and date)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-data-ID-and-date/m-p/571686#M161291</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Please please PLEASE share your wisdom!! I know it is kind of easy but for me so demanding...&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The quickest way to get help, is to put in some effort and then show what you've tried. That's usually more than enough to get a decent answer.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2019 02:56:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-data-ID-and-date/m-p/571686#M161291</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-08T02:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: Matching data (ID and date)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-data-ID-and-date/m-p/572187#M161461</link>
      <description>&lt;P&gt;well.. I am actually working on a massive data set but I am too clumsy. I have utilized my codes on the internet but all was not the answer...&lt;/P&gt;&lt;P&gt;maybe it is better to post a new post and attach my code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you:)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 18:40:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-data-ID-and-date/m-p/572187#M161461</guid>
      <dc:creator>JKCho</dc:creator>
      <dc:date>2019-07-09T18:40:39Z</dc:date>
    </item>
  </channel>
</rss>

