<?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: finding min and max date from multiple dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579803#M164644</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/2837"&gt;@Rahul_SAS&lt;/a&gt;&amp;nbsp;, with more than 100 posts here, you should know that posting &lt;U&gt;Excel spreadsheets&lt;/U&gt; is not the way to supply example &lt;U&gt;SAS datasets&lt;/U&gt;.&lt;/P&gt;
&lt;P&gt;Please use a data step with datalines, as you have already been asked multiple times and shown how to do it, eg here:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/multiple-firs-var-not-working/m-p/500913/highlight/true#M133472" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/multiple-firs-var-not-working/m-p/500913/highlight/true#M133472&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Aug 2019 06:06:44 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-08-08T06:06:44Z</dc:date>
    <item>
      <title>finding min and max date from multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579746#M164618</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please help me to find a max and a min date value from 10 date fields (date1, date2, date3...date10). And further, need to get all intermediate months between those two min and max date in a new column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks&lt;/P&gt;
&lt;P&gt;Rahul&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2019 20:07:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579746#M164618</guid>
      <dc:creator>Rahul_SAS</dc:creator>
      <dc:date>2019-08-07T20:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: finding min and max date from multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579761#M164625</link>
      <description>&lt;P&gt;Could&amp;nbsp; you please provide sample data and expected out for better response.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2019 20:51:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579761#M164625</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-08-07T20:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: finding min and max date from multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579763#M164627</link>
      <description>What do you mean by intermediate months? Are those the months that are present in the data or you want all months? &lt;BR /&gt;&lt;BR /&gt;I would recommend first transposing your data to a long format and then doing this, it's easier to work with and you can use BY group processing.</description>
      <pubDate>Wed, 07 Aug 2019 21:15:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579763#M164627</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-07T21:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: finding min and max date from multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579788#M164636</link>
      <description>&lt;P&gt;If you need min and max per observation, you can use something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;min = min(of date1-date10);
max = max(of date1-date10);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Assuming that you have proper sas-dates.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 04:32:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579788#M164636</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-08-08T04:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: finding min and max date from multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579794#M164640</link>
      <description>&lt;P&gt;please find the sample data and required result.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 05:20:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579794#M164640</guid>
      <dc:creator>Rahul_SAS</dc:creator>
      <dc:date>2019-08-08T05:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: finding min and max date from multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579795#M164641</link>
      <description>&lt;P&gt;no, its not per observation.&lt;/P&gt;
&lt;P&gt;I need to have min and max date from across all date fields.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 05:22:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579795#M164641</guid>
      <dc:creator>Rahul_SAS</dc:creator>
      <dc:date>2019-08-08T05:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: finding min and max date from multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579799#M164642</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/2837"&gt;@Rahul_SAS&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;I'm not sure whether your "&lt;SPAN&gt;get all intermediate months between those two min and max date in a new column" means the inclusive number of months of their list in some date format. Either way, try this (you haven't provided any sample data, so I've just mocked up 5 dates date1-date5 in the first step):&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;                                                                   
  array date date1-date5 ;                                                    
  do _n_ = 1 to 5 ;                                                           
    do over date ;                                                            
      date = 20000 + ceil (ranuni(1) * 365) ;                                 
    end ;                                                                     
    output ;                                                                  
  end ;                                                                       
  format date: yymmdd10. ;                                                    
run ;                                                                         
                                                                              
data want ;                                                                   
  set have ;                                                                  
  mindate = min (of date:) ;                                                  
  maxdate = max (of date:) ;                                                  
  N_months = intck ("mon", mindate, maxdate) ;                                
  length months $ 32767 ;                                                     
  do _n_ = 0 to N_months ;                                                    
    months = catx (", ", months, put (intnx ("mon", mindate, _n_), yymmd7.)) ; 
  end ;                                                                       
  format mindate maxdate yymmdd10. ;                                          
run ;                                                                         
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Kind regards&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Paul D.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 05:52:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579799#M164642</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-08-08T05:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: finding min and max date from multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579803#M164644</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/2837"&gt;@Rahul_SAS&lt;/a&gt;&amp;nbsp;, with more than 100 posts here, you should know that posting &lt;U&gt;Excel spreadsheets&lt;/U&gt; is not the way to supply example &lt;U&gt;SAS datasets&lt;/U&gt;.&lt;/P&gt;
&lt;P&gt;Please use a data step with datalines, as you have already been asked multiple times and shown how to do it, eg here:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Programming/multiple-firs-var-not-working/m-p/500913/highlight/true#M133472" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/multiple-firs-var-not-working/m-p/500913/highlight/true#M133472&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 06:06:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579803#M164644</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-08-08T06:06:44Z</dc:date>
    </item>
    <item>
      <title>Re: finding min and max date from multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579804#M164645</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/2837"&gt;@Rahul_SAS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;no, its not per observation.&lt;/P&gt;
&lt;P&gt;I need to have min and max date from across all date fields.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then please post data in usable form and show the output you expect form this data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 06:15:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579804#M164645</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-08-08T06:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: finding min and max date from multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579805#M164646</link>
      <description>&lt;P&gt;You may try the below code and WANT3 will have the expected results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
min=min(of date1-date5);
max=max(of date1-date5);
format min max date9.;
run;

proc sql;
create table want2 as select min(min) as min2 format=date9., max(max) as max2 format=date9. from want ;
quit;

data want3;
set want2;
do date=min2 to max2;
monyear=put(date,monyy7.);
output;
end;
format date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Aug 2019 06:20:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579805#M164646</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-08-08T06:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: finding min and max date from multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579807#M164647</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/2837"&gt;@Rahul_SAS&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;If you'd like to get clear help, you have to express your request clearly, too. Field=variable. Observation (i.e. record or row) consist of variables, i.e. of fields. Hence, "per observation" means "across fields in this observation". The way you've formulated your question, it looks like this picture:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   date1      date2      date3      date4      date5     mindate    maxdate 
----------------------------------------------------------------------------
2014-12-11 2015-09-24 2015-02-27 2015-01-07 2015-09-06 2014-12-11 2015-09-24
2015-09-23 2015-04-21 2015-04-17 2014-10-23 2014-10-29 2014-10-23 2015-09-23
2015-07-31 2015-04-14 2015-08-12 2014-10-29 2015-09-19 2014-10-29 2015-09-19
2015-01-21 2015-01-12 2015-06-13 2015-09-26 2014-12-26 2014-12-26 2015-09-26
2015-06-13 2015-03-04 2015-04-26 2015-01-17 2015-03-27 2015-01-17 2015-06-13
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If this is different from what you have in mind, show your picture. As they say, it's worth a thousand words.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 06:50:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579807#M164647</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-08-08T06:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: finding min and max date from multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579815#M164649</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;You can do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do date=min2 to max2;
monyear=put(date,monyy7.);
output;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But then you'll have to dedup MONYEAR since DATE iterates through each &lt;EM&gt;date&lt;/EM&gt; from MIN2 to MAX2, and hence MONYEAR will be the same for every day of the same month.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 07:43:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579815#M164649</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-08-08T07:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: finding min and max date from multiple dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579819#M164650</link>
      <description>&lt;P&gt;Your data makes NO sense.&lt;/P&gt;
&lt;P&gt;Your "have.xlsx" contains only dates in June 2019, while your "want.xlsx" goes back to February 2018 and ends in July 2019. Please make up your mind, and supply USABLE example data that REALLY illustrates what you want, and give us the REAL logic behind it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See Maxim 42.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Right now, my answer can only be "42".&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 08:24:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-min-and-max-date-from-multiple-dates/m-p/579819#M164650</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-08-08T08:24:16Z</dc:date>
    </item>
  </channel>
</rss>

