<?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: max min &amp;amp; median for date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/max-min-amp-median-for-date/m-p/570198#M160772</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/200312"&gt;@Srigyan&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The challenge here is that SAS doesn't have a data type of DATE and though the only way to identify columns with SAS date values is via the SAS format applied.&lt;/P&gt;
&lt;P&gt;Below code demonstrates the approach. You will have to add more SAS Date format names in order to make this more generic.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Table1;
  input product $ start_date :date7. end_date:date7. Price;
  format start_date end_date date9. other_dttm datetime20.;
  other_dttm=datetime();
  datalines;
p1 01Jan17 18Jan18 15
p1 19Jan18 15Jul18 30
p1 16Jul18 31Mar19 24
p2 08Jan17 31Dec17 17
p2 01Jan18 15Mar18 19
p2 26Jul18 31Mar19 18
;

proc sql noprint;
  select name into :col_list separated by ' '
  from dictionary.columns
  where libname='WORK' and memname='TABLE1' 
    and upcase(format) like 'DATE%' 
    and upcase(format) not like 'DATETIME%'
  ;
quit;

proc tabulate data=Table1;
  var &amp;amp;col_list;
  table &amp;amp;col_list,
    n nmiss (min max median)*f=mmddyy10. range;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've been hoping that function FMTINFO() could make this task a bit simpler but the function didn't even recognise DATE7. as a date format with my rather recent version of SAS.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 477px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30659iDD22A0194BB9BB35/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Jul 2019 12:05:55 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2019-07-01T12:05:55Z</dc:date>
    <item>
      <title>max min &amp; median for date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/max-min-amp-median-for-date/m-p/570189#M160771</link>
      <description>&lt;P&gt;I have following table;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Table1;
  input product $ start_date :date7. end_date:date7. Price;
 format start_date end_date date9.;
  datalines;
p1 01Jan17 18Jan18 15
p1 19Jan18 15Jul18 30
p1 16Jul18 31Mar19 24
p2 08Jan17 31Dec17 17
p2 01Jan18 15Mar18 19
p2 26Jul18 31Mar19 18
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;i want to run following codes on this tables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data=Table1;
var start_date end_date;
table start_date end_date,
 n nmiss (min max median)*f=mmddyy10. range;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;in var and table option I am choosing variable manual, I want this code to choose all date variable itself.&lt;/P&gt;&lt;P&gt;i.e. I don't need to mentioned date variable myself, program should choose all the variable in date format and run this code on date variable only.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2019 11:34:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/max-min-amp-median-for-date/m-p/570189#M160771</guid>
      <dc:creator>Srigyan</dc:creator>
      <dc:date>2019-07-01T11:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: max min &amp; median for date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/max-min-amp-median-for-date/m-p/570198#M160772</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/200312"&gt;@Srigyan&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The challenge here is that SAS doesn't have a data type of DATE and though the only way to identify columns with SAS date values is via the SAS format applied.&lt;/P&gt;
&lt;P&gt;Below code demonstrates the approach. You will have to add more SAS Date format names in order to make this more generic.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Table1;
  input product $ start_date :date7. end_date:date7. Price;
  format start_date end_date date9. other_dttm datetime20.;
  other_dttm=datetime();
  datalines;
p1 01Jan17 18Jan18 15
p1 19Jan18 15Jul18 30
p1 16Jul18 31Mar19 24
p2 08Jan17 31Dec17 17
p2 01Jan18 15Mar18 19
p2 26Jul18 31Mar19 18
;

proc sql noprint;
  select name into :col_list separated by ' '
  from dictionary.columns
  where libname='WORK' and memname='TABLE1' 
    and upcase(format) like 'DATE%' 
    and upcase(format) not like 'DATETIME%'
  ;
quit;

proc tabulate data=Table1;
  var &amp;amp;col_list;
  table &amp;amp;col_list,
    n nmiss (min max median)*f=mmddyy10. range;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've been hoping that function FMTINFO() could make this task a bit simpler but the function didn't even recognise DATE7. as a date format with my rather recent version of SAS.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 477px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30659iDD22A0194BB9BB35/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2019 12:05:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/max-min-amp-median-for-date/m-p/570198#M160772</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-07-01T12:05:55Z</dc:date>
    </item>
  </channel>
</rss>

