<?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: How to: Determine if YEAR in Table 2 is within the time range of Table 1 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Determine-if-YEAR-in-Table-2-is-within-the-time-range-of/m-p/897819#M354846</link>
    <description>&lt;P&gt;MDY has nothing to do with this issue. The issue is that you don't have enough memory because the tables are so large.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please give us the information about how many rows and columns are in each data set.&lt;/P&gt;</description>
    <pubDate>Mon, 09 Oct 2023 14:12:31 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-10-09T14:12:31Z</dc:date>
    <item>
      <title>How to: Determine if YEAR in Table 2 is within the time range of Table 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Determine-if-YEAR-in-Table-2-is-within-the-time-range-of/m-p/897785#M354829</link>
      <description>&lt;P&gt;I currently have two tables have1 and have2, and I want to determine if the YEAR corresponding to each NAME in have2 is within the time range of have1 [START END]. If marked as 1, otherwise it is 0.&lt;/P&gt;&lt;P&gt;I hope to match through the common CODE of two tables and obtain Want.&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2023 11:08:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Determine-if-YEAR-in-Table-2-is-within-the-time-range-of/m-p/897785#M354829</guid>
      <dc:creator>Alice_SAS</dc:creator>
      <dc:date>2023-10-09T11:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to: Determine if YEAR in Table 2 is within the time range of Table 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Determine-if-YEAR-in-Table-2-is-within-the-time-range-of/m-p/897786#M354830</link>
      <description>&lt;P&gt;Here is the data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have1;&lt;BR /&gt;input start: YYMMDD8. end: YYMMDD8. name:$1. code;&lt;BR /&gt;format start YYMMDDn8. end YYMMDDn8.;&lt;BR /&gt;datalines;&lt;BR /&gt;20050712 20060531 A 83265&lt;BR /&gt;20100624 20130812 B 79080&lt;BR /&gt;20040526 20051109 C 35423&lt;BR /&gt;20140401 20160418 D 69105&lt;BR /&gt;20170419 20180424 E 53272&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have2;&lt;BR /&gt;input year name:$1. code;&lt;BR /&gt;datalines;&lt;BR /&gt;2011 A 83265&lt;BR /&gt;2012 A 83265&lt;BR /&gt;2007 B 79080&lt;BR /&gt;2008 B 79080&lt;BR /&gt;2009 B 79080&lt;BR /&gt;2010 B 79080&lt;BR /&gt;2012 D 69105&lt;BR /&gt;2013 D 69105&lt;BR /&gt;2014 D 69105&lt;BR /&gt;2015 D 69105&lt;BR /&gt;2016 D 69105&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to obtain:&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;input year name:$1. code exist;&lt;BR /&gt;datalines;&lt;BR /&gt;2011 A 83265 0&lt;BR /&gt;2012 A 83265 0&lt;BR /&gt;2007 B 79080 0&lt;BR /&gt;2008 B 79080 0&lt;BR /&gt;2009 B 79080 0&lt;BR /&gt;2010 B 79080 1&lt;BR /&gt;2012 D 69105 0&lt;BR /&gt;2013 D 69105 0&lt;BR /&gt;2014 D 69105 1&lt;BR /&gt;2015 D 69105 1&lt;BR /&gt;2016 D 69105 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2023 11:09:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Determine-if-YEAR-in-Table-2-is-within-the-time-range-of/m-p/897786#M354830</guid>
      <dc:creator>Alice_SAS</dc:creator>
      <dc:date>2023-10-09T11:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to: Determine if YEAR in Table 2 is within the time range of Table 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Determine-if-YEAR-in-Table-2-is-within-the-time-range-of/m-p/897787#M354831</link>
      <description>&lt;P&gt;Do you mean that ANY PART of the year in HAVE2 is contained between the dates in HAVE1?&lt;/P&gt;
&lt;P&gt;Or do you mean that ALL of the year in HAVE2 is contained between the dates in HAVE1?&lt;/P&gt;
&lt;P&gt;Or do you mean something else?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2023 11:17:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Determine-if-YEAR-in-Table-2-is-within-the-time-range-of/m-p/897787#M354831</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-09T11:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to: Determine if YEAR in Table 2 is within the time range of Table 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Determine-if-YEAR-in-Table-2-is-within-the-time-range-of/m-p/897790#M354834</link>
      <description>&lt;P&gt;My idea is that for &lt;EM&gt;have2&lt;/EM&gt;, first I need to determine whether there is a corresponding CODE in &lt;EM&gt;have1&lt;/EM&gt;. If so, I will then separately determine whether each year is within the time range in have1.&lt;/P&gt;&lt;P&gt;For example, for the first line in &lt;EM&gt;have2,&lt;/EM&gt; I first determine that CODE 83265 is within &lt;EM&gt;have1&lt;/EM&gt;, and then I verify whether year 2011 is within the time range of 20050712 20060531. Obviously, it is not, so I let exist = 0.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2023 11:28:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Determine-if-YEAR-in-Table-2-is-within-the-time-range-of/m-p/897790#M354834</guid>
      <dc:creator>Alice_SAS</dc:creator>
      <dc:date>2023-10-09T11:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to: Determine if YEAR in Table 2 is within the time range of Table 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Determine-if-YEAR-in-Table-2-is-within-the-time-range-of/m-p/897791#M354835</link>
      <description>&lt;P&gt;Thanks, but I don't think you have answered my questions clearly.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you mean that ANY PART of the year in HAVE2 is contained between the dates in HAVE1?&lt;/P&gt;
&lt;P&gt;Or do you mean that ALL of the year in HAVE2 is contained between the dates in HAVE1?&lt;/P&gt;
&lt;P&gt;Or do you mean something else?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 09 Oct 2023 11:29:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Determine-if-YEAR-in-Table-2-is-within-the-time-range-of/m-p/897791#M354835</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-09T11:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to: Determine if YEAR in Table 2 is within the time range of Table 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Determine-if-YEAR-in-Table-2-is-within-the-time-range-of/m-p/897792#M354836</link>
      <description>&lt;P&gt;I understand your question. Any PART is OK, thank you very much!&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2023 11:32:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Determine-if-YEAR-in-Table-2-is-within-the-time-range-of/m-p/897792#M354836</guid>
      <dc:creator>Alice_SAS</dc:creator>
      <dc:date>2023-10-09T11:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to: Determine if YEAR in Table 2 is within the time range of Table 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Determine-if-YEAR-in-Table-2-is-within-the-time-range-of/m-p/897802#M354841</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    create table want as select b.*,
    case when mdy(1,1,year) between start and end
        or mdy(12,31,year) between start and end then 1 else 0 end as exist
    from have1 as a right join have2 as b
    on a.code=b.code and a.name=b.name;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Oct 2023 11:55:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Determine-if-YEAR-in-Table-2-is-within-the-time-range-of/m-p/897802#M354841</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-09T11:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to: Determine if YEAR in Table 2 is within the time range of Table 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Determine-if-YEAR-in-Table-2-is-within-the-time-range-of/m-p/897813#M354844</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I had a very similar idea, but then realized that it would fail if &lt;FONT face="courier new,courier"&gt;start&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;end&lt;/FONT&gt; were dates &lt;EM&gt;in the same year&lt;/EM&gt;, e.g., from April and October, respectively. Therefore, the suggestion I had prepared used the criterion &lt;FONT face="courier new,courier"&gt;year(start)&amp;lt;=year&amp;lt;=year(end)&lt;/FONT&gt;, possibly in a CASE-WHEN expression if the case "code not found in HAVE1" should be distinguished from "code found, but year criterion not met":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select a.*, case when missing(b.code) then .
              else year(start)&amp;lt;=year&amp;lt;=year(end)
            end as exist
from have2 a left join have1 b
on a.code=b.code
order by name, year;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Oct 2023 13:40:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Determine-if-YEAR-in-Table-2-is-within-the-time-range-of/m-p/897813#M354844</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2023-10-09T13:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to: Determine if YEAR in Table 2 is within the time range of Table 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Determine-if-YEAR-in-Table-2-is-within-the-time-range-of/m-p/897816#M354845</link>
      <description>&lt;P&gt;Thank you for your answer. Although you solved my problem. But in reality, my tables have1 and have2 are both very large. I used your method but the operation failed because there was no memory. I think the problem lies in mdy(1,1, year). Is there a more efficient method? Thanks！&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2023 13:44:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Determine-if-YEAR-in-Table-2-is-within-the-time-range-of/m-p/897816#M354845</guid>
      <dc:creator>Alice_SAS</dc:creator>
      <dc:date>2023-10-09T13:44:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to: Determine if YEAR in Table 2 is within the time range of Table 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Determine-if-YEAR-in-Table-2-is-within-the-time-range-of/m-p/897819#M354846</link>
      <description>&lt;P&gt;MDY has nothing to do with this issue. The issue is that you don't have enough memory because the tables are so large.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please give us the information about how many rows and columns are in each data set.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2023 14:12:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Determine-if-YEAR-in-Table-2-is-within-the-time-range-of/m-p/897819#M354846</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-09T14:12:31Z</dc:date>
    </item>
  </channel>
</rss>

