<?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: Identify/List all date fields in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identify-List-all-date-fields/m-p/727203#M226119</link>
    <description>It looks like this will work, thank you!&lt;BR /&gt;</description>
    <pubDate>Wed, 17 Mar 2021 17:52:31 GMT</pubDate>
    <dc:creator>ProcWes</dc:creator>
    <dc:date>2021-03-17T17:52:31Z</dc:date>
    <item>
      <title>Identify/List all date fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-List-all-date-fields/m-p/727124#M226082</link>
      <description>&lt;P&gt;I am trying to identify all date fields in my data.&amp;nbsp; It is a challenge because SAS stores them as number, so if I do something like _numeric_, I get both the numbers and the dates.&amp;nbsp; If they were all the same format, contents would work to find them, but there are many acceptable date formats.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's an example.&amp;nbsp; How could I catch both DATE which is in the sashelp data and FAKE which I'm creating in a different format?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
set sashelp.stocks;
format xx mmddyy10.;
fake = today();
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Mar 2021 14:39:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-List-all-date-fields/m-p/727124#M226082</guid>
      <dc:creator>ProcWes</dc:creator>
      <dc:date>2021-03-17T14:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: Identify/List all date fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-List-all-date-fields/m-p/727155#M226098</link>
      <description>&lt;P&gt;I can think of several ways to identify or guess which fields are dates:&lt;/P&gt;
&lt;P&gt;1) As you noticed all dates are NUM type but can be string too (like "20210317"&amp;nbsp; todays date);&lt;/P&gt;
&lt;P&gt;2) For NUM type check FORMAT or INFORMAT compared to a long list of possibilities.&lt;/P&gt;
&lt;P&gt;3) If no FORMAT nor INFORMAT assigned then guessing is the only possibility:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;If you know your data then non missing INTEGERs may be dates if they are in logical range.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;It needs checking all the variables' values in all observations of the data set.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 176px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56062iF136042B3DC39B9C/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Note: dtn = input(dtx,date9.);&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4) Check variable &lt;U&gt;names&lt;/U&gt; according to expected language, file was created by.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;For English - most names will include 'date',&amp;nbsp; 'dt', 'year', 'yy', 'month', 'mon', 'mm' etc..&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Human eyes scanning&amp;nbsp; of the variable names are faster then any programming.&lt;/P&gt;
&lt;P&gt;5) Check variable &lt;U&gt;labels&lt;/U&gt; if exist or any other Metadate or documentation you might have.&lt;/P&gt;
&lt;P&gt;6) If you have already programs using this dataset - check how the program relates to the data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;which functions, formats or informats are used with each guessed variable.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Mar 2021 16:09:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-List-all-date-fields/m-p/727155#M226098</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-03-17T16:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Identify/List all date fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-List-all-date-fields/m-p/727197#M226117</link>
      <description>&lt;P&gt;If you do not attach a standard date informat or format to the variable, or name it with the word "date" somewhere in the name or have the word "date" in a label there is no way to "identify all".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if you have character values that look like dates then even more problematic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can search variable metadata for the characteristics above in the SASHELP.Volumns view (or dictionary.columns if using Proc SQL).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want "guesses" you could look for numeric variables whose values are integer and in an expected range of values that might be dates but I would be very skeptical about the results in general.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Mar 2021 17:27:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-List-all-date-fields/m-p/727197#M226117</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-17T17:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: Identify/List all date fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-List-all-date-fields/m-p/727202#M226118</link>
      <description>&lt;P&gt;Use the FMTINFO() function to find the variables that date category formats attached to them.&lt;/P&gt;
&lt;P&gt;Use the output of PROC CONTENTS to get the FORMAT name without the width/decimal specication.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=HAVE out=contents noprint; run;
proc sql noprint;
select name into :datevar separated by ' '
  from contents
  where 'date'=fmtinfo(format,'cat')
;
%let ndates=&amp;amp;sqlobs;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Jun 2023 12:17:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-List-all-date-fields/m-p/727202#M226118</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-05T12:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: Identify/List all date fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-List-all-date-fields/m-p/727203#M226119</link>
      <description>It looks like this will work, thank you!&lt;BR /&gt;</description>
      <pubDate>Wed, 17 Mar 2021 17:52:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-List-all-date-fields/m-p/727203#M226119</guid>
      <dc:creator>ProcWes</dc:creator>
      <dc:date>2021-03-17T17:52:31Z</dc:date>
    </item>
    <item>
      <title>Re: Identify/List all date fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-List-all-date-fields/m-p/879214#M347354</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;syntax error in the code - should be "PROC CONTENTS ..."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc contents data=HAVE out=contents noprint; run;
proc sql noprint;
select name into :datevar separated by ' '
  from contents
  where 'date'=fmtinfo(format,'cat')
;
%let ndates=&amp;amp;sqlobs;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Jun 2023 08:31:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-List-all-date-fields/m-p/879214#M347354</guid>
      <dc:creator>ishmo65</dc:creator>
      <dc:date>2023-06-05T08:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: Identify/List all date fields</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-List-all-date-fields/m-p/879236#M347358</link>
      <description>&lt;P&gt;Yes.&amp;nbsp; Thanks.&amp;nbsp; Fixed it now.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jun 2023 12:18:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-List-all-date-fields/m-p/879236#M347358</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-05T12:18:11Z</dc:date>
    </item>
  </channel>
</rss>

