<?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: Convert Numeric Date to Character in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-Numeric-Date-to-Character/m-p/482873#M125142</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;   
   Date='02JAN2018'd;
   CharDate=put(Date, yymmdd10.);
   format Date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, not a good idea to have dates stored as character...&lt;/P&gt;</description>
    <pubDate>Tue, 31 Jul 2018 17:03:52 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2018-07-31T17:03:52Z</dc:date>
    <item>
      <title>Convert Numeric Date to Character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Numeric-Date-to-Character/m-p/482868#M125140</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a date variable that is numeric ((02JAN2018) ) with date9. format and date 9 informat&amp;nbsp; length 8.&lt;/P&gt;&lt;P&gt;I would like it to be character date yymmdd10.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your help will be appreciated&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 16:46:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Numeric-Date-to-Character/m-p/482868#M125140</guid>
      <dc:creator>Dhana18</dc:creator>
      <dc:date>2018-07-31T16:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Numeric Date to Character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Numeric-Date-to-Character/m-p/482871#M125141</link>
      <description>&lt;P&gt;There is no such thing as a character date in SAS. You can convert the date to a plain old character string, which is only useful in labels and titles and reports. If you care going to do additional computations or work with the date, you need to leave it as numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the conversion to character:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;char_date = put(date,yymmdd10.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Perhaps you meant that you want to leave the variable as numeric but with a different format? That would be much more useful and reasonable than creating a character string. In that case, just change the format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Editor's note:&amp;nbsp; &lt;BR /&gt;As PaigeMiller noted, converting the date to a character string is different than reformatting the date with a format that uses characters.&amp;nbsp; If reformatting is the goal, Astounding provides example code that can be used in a Proc step or a DATA step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format datevar yymmdd10.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2022 15:42:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Numeric-Date-to-Character/m-p/482871#M125141</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-20T15:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Numeric Date to Character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Numeric-Date-to-Character/m-p/482873#M125142</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;   
   Date='02JAN2018'd;
   CharDate=put(Date, yymmdd10.);
   format Date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, not a good idea to have dates stored as character...&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 17:03:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Numeric-Date-to-Character/m-p/482873#M125142</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-07-31T17:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Numeric Date to Character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Numeric-Date-to-Character/m-p/482888#M125150</link>
      <description>&lt;P&gt;If you are not happy with the DATE9 format, just use&amp;nbsp;a different format:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;format datevar yymmdd10.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can add that statement in a PROC step, in which case the format is used just for the duration of the procedure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you can add it in a DATA step, in which case the format becomes the default format going forward from that point.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 17:32:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Numeric-Date-to-Character/m-p/482888#M125150</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-07-31T17:32:09Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Numeric Date to Character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Numeric-Date-to-Character/m-p/482903#M125156</link>
      <description>&lt;P&gt;Thank you for your response, i would like to create a new character variable with yymmdd10. format.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 18:15:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Numeric-Date-to-Character/m-p/482903#M125156</guid>
      <dc:creator>Dhana18</dc:creator>
      <dc:date>2018-07-31T18:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Numeric Date to Character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Numeric-Date-to-Character/m-p/482904#M125157</link>
      <description>&lt;P&gt;Thank you! I just changed the format and it worked!&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 18:25:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Numeric-Date-to-Character/m-p/482904#M125157</guid>
      <dc:creator>Dhana18</dc:creator>
      <dc:date>2018-07-31T18:25:07Z</dc:date>
    </item>
  </channel>
</rss>

