<?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: Change DATE formats to DDMMYYS10. for ALL (unknown number) date variables in a data set/LIBRARY in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Change-DATE-formats-to-DDMMYYS10-for-ALL-unknown-number-date/m-p/366662#M64878</link>
    <description>Thanks Reeza for your hint. No they have no standard naming and they have different date formats DATE, DDMMYY etc. If I could isolate ALL date variables then I could change all their different formats to DDMMYYS10. .. There must be a way. Thanks again.</description>
    <pubDate>Tue, 13 Jun 2017 15:54:48 GMT</pubDate>
    <dc:creator>Zeus_Olympous</dc:creator>
    <dc:date>2017-06-13T15:54:48Z</dc:date>
    <item>
      <title>Change DATE formats to DDMMYYS10. for ALL (unknown number) date variables in a data set/LIBRARY</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Change-DATE-formats-to-DDMMYYS10-for-ALL-unknown-number-date/m-p/366637#M64876</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have either a data set &lt;STRONG&gt;or&lt;/STRONG&gt; many datasets in a LIBRARY that contain &lt;STRONG&gt;unknown&lt;/STRONG&gt; number of date variables in possibly different date formats.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to &lt;STRONG&gt;CHANGE&lt;/STRONG&gt; the various date formats that belong&lt;STRONG&gt; to unknown number of date variables&lt;/STRONG&gt; in my dataset &lt;STRONG&gt;or&lt;/STRONG&gt; in my library &lt;STRONG&gt;to DDMMYYS10.&lt;/STRONG&gt; (same for ALL date variables).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any function in SAS&amp;nbsp;that I can apply it to make It happen.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your guidance.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 15:27:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Change-DATE-formats-to-DDMMYYS10-for-ALL-unknown-number-date/m-p/366637#M64876</guid>
      <dc:creator>Zeus_Olympous</dc:creator>
      <dc:date>2017-06-13T15:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Change DATE formats to DDMMYYS10. for ALL (unknown number) date variables in a data set/LIBRARY</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Change-DATE-formats-to-DDMMYYS10-for-ALL-unknown-number-date/m-p/366644#M64877</link>
      <description>&lt;P&gt;Can you identify the date variables in any way? Do they have a consistent naming structure or some other way they can be identified?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise, the answer is no. The reason is SAS stores dates as numbers, so telling the difference between an actual number vs a date is not easy. Search on here for this question, it's been &amp;nbsp;asked and answered a few times and has a lengthy discussion that would be helpful as background.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 15:29:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Change-DATE-formats-to-DDMMYYS10-for-ALL-unknown-number-date/m-p/366644#M64877</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-13T15:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: Change DATE formats to DDMMYYS10. for ALL (unknown number) date variables in a data set/LIBRARY</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Change-DATE-formats-to-DDMMYYS10-for-ALL-unknown-number-date/m-p/366662#M64878</link>
      <description>Thanks Reeza for your hint. No they have no standard naming and they have different date formats DATE, DDMMYY etc. If I could isolate ALL date variables then I could change all their different formats to DDMMYYS10. .. There must be a way. Thanks again.</description>
      <pubDate>Tue, 13 Jun 2017 15:54:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Change-DATE-formats-to-DDMMYYS10-for-ALL-unknown-number-date/m-p/366662#M64878</guid>
      <dc:creator>Zeus_Olympous</dc:creator>
      <dc:date>2017-06-13T15:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: Change DATE formats to DDMMYYS10. for ALL (unknown number) date variables in a data set/LIBRARY</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Change-DATE-formats-to-DDMMYYS10-for-ALL-unknown-number-date/m-p/366667#M64880</link>
      <description>&lt;P&gt;About the only way to be reasonably sure that a variable is date-valued is to check a format. I might start with this code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; select distinct format&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; from dictionary.columns&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; where libname='YOURLIB';&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will find all assigned formats. Identify those that are date formats. NOTE: Make sure they are not datetime formats.&lt;/P&gt;
&lt;P&gt;You can then use that information to further select&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table datefmts as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select memname, name&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from dictionary.columns&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where libname='YOURLIB'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;and upcase(&amp;nbsp;format) in ('DATE7.' ,'MMDDYY10.')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;The list of date formats comes from the previous proc sql step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can then use the resulting the datefmts data set to call proc datasets and modify the data set variable formats using Proc Datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that any variables that just happen to contain things that look like dates, such as character variables of '01/25/2015' or numerics line 20170512 will not have a chance of being identified with formats. You might be able to find common date related variable name parts in the Dictionary.columns data set such as "StartDate" "End_Date" "Purchase_date" but if they don't have an actual date format associated then you'll need to create a SAS date valued variable and apply the format there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 15:57:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Change-DATE-formats-to-DDMMYYS10-for-ALL-unknown-number-date/m-p/366667#M64880</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-13T15:57:28Z</dc:date>
    </item>
    <item>
      <title>Re: Change DATE formats to DDMMYYS10. for ALL (unknown number) date variables in a data set/LIBRARY</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Change-DATE-formats-to-DDMMYYS10-for-ALL-unknown-number-date/m-p/366678#M64882</link>
      <description>&lt;P&gt;Like I mentioned, if you can assume something you can sort of do this, but you cannot GUARANTEE that it's 100% correct.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Under the assumption that the variable will already have a Date/Datetime format there are&amp;nbsp;some solutions on StackOverflow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/38470459/sas-programatically-identifying-numeric-variables-that-represent-date-time-dat" target="_blank"&gt;https://stackoverflow.com/questions/38470459/sas-programatically-identifying-numeric-variables-that-represent-date-time-dat&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 16:09:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Change-DATE-formats-to-DDMMYYS10-for-ALL-unknown-number-date/m-p/366678#M64882</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-13T16:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Change DATE formats to DDMMYYS10. for ALL (unknown number) date variables in a data set/LIBRARY</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Change-DATE-formats-to-DDMMYYS10-for-ALL-unknown-number-date/m-p/366839#M64884</link>
      <description>&lt;P&gt;With the SAS 9.4 TS1M3 release there is a new FMTINFO() function&amp;nbsp;that should help with this.&lt;/P&gt;
&lt;P&gt;So just use PROC CONTENTS to get the list of variables in the library or dataset. Note that for this job PROC CONTENTS works much better than SASHELP.VCOLUMN since the FORMAT variable has the bare format name without the width and decimal settings.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=mylib._all_ noprint out=contents;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you can use a data step like this to generate PROC DATASET code to change&amp;nbsp;the formats attached to the date variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set contents;
  where fmtinfo(format,'cat')='date';
  by libname memname ;
  if first.libname then call execute(catx(' ','proc datasets nolist lib=',libname,';')) ;
  if first.memname then call execute(catx(' ','modify',memname,';format',name)) ;
  else call execute(' '||trim(name)) ;
  if last.memname then call execute(' DDMMYYS10.; run;') ;
  if last.libname then call execute('quit;') ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Personally I would use a format like DATE or YYMMDD instead to avoid the confusion between Dec 10th and Oct 12th &amp;nbsp;that can happen if you use either MMDDYY or DDMMYY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 04:59:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Change-DATE-formats-to-DDMMYYS10-for-ALL-unknown-number-date/m-p/366839#M64884</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-14T04:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: Change DATE formats to DDMMYYS10. for ALL (unknown number) date variables in a data set/LIBRARY</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Change-DATE-formats-to-DDMMYYS10-for-ALL-unknown-number-date/m-p/366884#M64885</link>
      <description>&lt;P&gt;Thanks a million, Tom!&amp;nbsp; Exactly what I wanted!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 09:03:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Change-DATE-formats-to-DDMMYYS10-for-ALL-unknown-number-date/m-p/366884#M64885</guid>
      <dc:creator>Zeus_Olympous</dc:creator>
      <dc:date>2017-06-14T09:03:23Z</dc:date>
    </item>
  </channel>
</rss>

