<?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 converting character date to numeric and then to date format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-numeric-and-then-to-date-format/m-p/590930#M169205</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Good morning,
i have a data set with a date in character format. I used this below code to change the character date into numeric date format.

data SURRGWED.CDC_Clinic_data ;
set  WEDSSUAT.Surrg_ForCDC_Clinic_v;
visdt=input(visdate,best10.);
drop visdate;
rename visdt=visdate;
run;

then used this code below to change the numeric date into date format.
 
data SURRGWED.CDC_Clinic_data_A ;
set SURRGWED.CDC_Clinic_data ;
format visdate mmddyy10.;
run;
 but it is nit working. the log says :
 data SURRGWED.CDC_Clinic_data_A ;
90   set SURRGWED.CDC_Clinic_data ;
91   format visdate mmddyy10.;
92   run;

NOTE: There were 6066 observations read from the data set SURRGWED.CDC_CLINIC_DATA.
NOTE: The data set SURRGWED.CDC_CLINIC_DATA_A has 6066 observations and 67 variables.
NOTE: DATA statement used (Total process time):
      real time           0.70 seconds
      cpu time            0.07 seconds

The out put is 
Visdate
.
.
.
.
.
.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please help!&lt;/P&gt;</description>
    <pubDate>Mon, 23 Sep 2019 14:22:55 GMT</pubDate>
    <dc:creator>Dhana18</dc:creator>
    <dc:date>2019-09-23T14:22:55Z</dc:date>
    <item>
      <title>converting character date to numeric and then to date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-numeric-and-then-to-date-format/m-p/590930#M169205</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Good morning,
i have a data set with a date in character format. I used this below code to change the character date into numeric date format.

data SURRGWED.CDC_Clinic_data ;
set  WEDSSUAT.Surrg_ForCDC_Clinic_v;
visdt=input(visdate,best10.);
drop visdate;
rename visdt=visdate;
run;

then used this code below to change the numeric date into date format.
 
data SURRGWED.CDC_Clinic_data_A ;
set SURRGWED.CDC_Clinic_data ;
format visdate mmddyy10.;
run;
 but it is nit working. the log says :
 data SURRGWED.CDC_Clinic_data_A ;
90   set SURRGWED.CDC_Clinic_data ;
91   format visdate mmddyy10.;
92   run;

NOTE: There were 6066 observations read from the data set SURRGWED.CDC_CLINIC_DATA.
NOTE: The data set SURRGWED.CDC_CLINIC_DATA_A has 6066 observations and 67 variables.
NOTE: DATA statement used (Total process time):
      real time           0.70 seconds
      cpu time            0.07 seconds

The out put is 
Visdate
.
.
.
.
.
.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please help!&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 14:22:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-numeric-and-then-to-date-format/m-p/590930#M169205</guid>
      <dc:creator>Dhana18</dc:creator>
      <dc:date>2019-09-23T14:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: converting character date to numeric and then to date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-numeric-and-then-to-date-format/m-p/590942#M169214</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212762"&gt;@Dhana18&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Good morning,
i have a data set with a date in character format. I used this below code to change the character date into numeric date format.

data SURRGWED.CDC_Clinic_data ;
set  WEDSSUAT.Surrg_ForCDC_Clinic_v;
visdt=input(visdate,best10.);
drop visdate;
rename visdt=visdate;
run;

then used this code below to change the numeric date into date format.
 
data SURRGWED.CDC_Clinic_data_A ;
set SURRGWED.CDC_Clinic_data ;
format visdate mmddyy10.;
run;
 but it is nit working. the log says :
 data SURRGWED.CDC_Clinic_data_A ;
90   set SURRGWED.CDC_Clinic_data ;
91   format visdate mmddyy10.;
92   run;

NOTE: There were 6066 observations read from the data set SURRGWED.CDC_CLINIC_DATA.
NOTE: The data set SURRGWED.CDC_CLINIC_DATA_A has 6066 observations and 67 variables.
NOTE: DATA statement used (Total process time):
      real time           0.70 seconds
      cpu time            0.07 seconds

The out put is 
Visdate
.
.
.
.
.
.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please help!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please show what your original visdate looked like.&lt;/P&gt;
&lt;P&gt;Likely you want to use one of the DATE informats to read the data not BEST.&lt;/P&gt;
&lt;P&gt;Since you are using a BEST10 I suspect the issue is that you have attempted to apply a date format to a value outside the range of actual date variables. The numeric value 6589335 corresponds to 31Dec20000 (yes 2 followed by &lt;STRONG&gt;5&lt;/STRONG&gt; zeroes). And that is only a 7 digit value. That is the largest date value SAS currently supports.&lt;/P&gt;
&lt;P&gt;Example of reading some common date looking values.&lt;/P&gt;
&lt;PRE&gt;data junk;
   x1= '15012019';
   y1=input(x1,ddmmyy8.);
   x2= '01152019';
   y2=input(x2,mmddyy8.);
   x3= '20190115';
   y3=input(x3,yymmdd8.);
   format y: date9.;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 14:38:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-numeric-and-then-to-date-format/m-p/590942#M169214</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-09-23T14:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: converting character date to numeric and then to date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-numeric-and-then-to-date-format/m-p/590957#M169224</link>
      <description>Here is the original date:&lt;BR /&gt;Visdate&lt;BR /&gt;0217/01/03&lt;BR /&gt;1/17/2017&lt;BR /&gt;1/6/2017&lt;BR /&gt;1/30/2017&lt;BR /&gt;1/23/2017&lt;BR /&gt;2/13/2017&lt;BR /&gt;</description>
      <pubDate>Mon, 23 Sep 2019 14:54:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-numeric-and-then-to-date-format/m-p/590957#M169224</guid>
      <dc:creator>Dhana18</dc:creator>
      <dc:date>2019-09-23T14:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: converting character date to numeric and then to date format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-numeric-and-then-to-date-format/m-p/590994#M169243</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212762"&gt;@Dhana18&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Here is the original date:&lt;BR /&gt;Visdate&lt;BR /&gt;0217/01/03&lt;BR /&gt;1/17/2017&lt;BR /&gt;1/6/2017&lt;BR /&gt;1/30/2017&lt;BR /&gt;1/23/2017&lt;BR /&gt;2/13/2017&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That would explain the missing values. None of those can be imported with Best or F formats.&lt;/P&gt;
&lt;P&gt;If that first one is actually supposed to be 2017/01/03 then you have mixed formats for your date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might be able to use the ANYDTDTE informat:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;visdt&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;visdate&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;anydtdte10&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;format visdt mmddyy10.;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;The question is if you are sure that with dates like 1/6/2017 where either the first or second value could be the month. You national language setting will determine the interpretation of such possibly ambiguous dates. At least you appear to have 4 digit years, otherwise unspecified date layouts can be messy&amp;nbsp; (01/02/03 could be 1) Jan 2, 2003,&amp;nbsp; 2) Feb 1, 2003 or 3)&amp;nbsp;Feb 3 2001 )&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;If it weren't for your first value I would suspect that the MMDDYY10. informat would work.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 16:53:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-character-date-to-numeric-and-then-to-date-format/m-p/590994#M169243</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-09-23T16:53:57Z</dc:date>
    </item>
  </channel>
</rss>

