<?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 Find Max between 2 date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-Max-between-2-date/m-p/808212#M318673</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have 2 datasets, 1 data with date and value, and the other data has start and end date.&lt;/P&gt;
&lt;P&gt;I want to find the Max value between start and end date.&lt;/P&gt;
&lt;P&gt;I can do it with my code below but I think there should be a better way using Proc SQL.&lt;/P&gt;
&lt;P&gt;Can you please help?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date value;
datalines;
1 5
2 6
3 8
4 1
5 9999
6 99

;run;

data condition;
input start end;
datalines;
2 4
3 6
;run;


proc sql;
create table temp as select * from condition as a left join have as b
on a.start&amp;lt;=b.date&amp;lt;a.end; quit;

proc sort data=temp; by start end descending value;

data want; set temp;
by start end;
if first.end; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 17 Apr 2022 01:37:48 GMT</pubDate>
    <dc:creator>hhchenfx</dc:creator>
    <dc:date>2022-04-17T01:37:48Z</dc:date>
    <item>
      <title>Find Max between 2 date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-Max-between-2-date/m-p/808212#M318673</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have 2 datasets, 1 data with date and value, and the other data has start and end date.&lt;/P&gt;
&lt;P&gt;I want to find the Max value between start and end date.&lt;/P&gt;
&lt;P&gt;I can do it with my code below but I think there should be a better way using Proc SQL.&lt;/P&gt;
&lt;P&gt;Can you please help?&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date value;
datalines;
1 5
2 6
3 8
4 1
5 9999
6 99

;run;

data condition;
input start end;
datalines;
2 4
3 6
;run;


proc sql;
create table temp as select * from condition as a left join have as b
on a.start&amp;lt;=b.date&amp;lt;a.end; quit;

proc sort data=temp; by start end descending value;

data want; set temp;
by start end;
if first.end; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 17 Apr 2022 01:37:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-Max-between-2-date/m-p/808212#M318673</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2022-04-17T01:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: Find Max between 2 date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-Max-between-2-date/m-p/808213#M318674</link>
      <description>&lt;P&gt;That one is better, short and clear&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data w; set condition;
max=0;
do i=start to end-1;
	set have point=i;
	if start&amp;lt;=date&amp;lt;end then do;
		if max&amp;lt;value then max=value;
	end;
end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 17 Apr 2022 01:47:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-Max-between-2-date/m-p/808213#M318674</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2022-04-17T01:47:22Z</dc:date>
    </item>
  </channel>
</rss>

