<?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: date to character format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349286#M273551</link>
    <description>&lt;P&gt;There are about 30 different SAS supplied&amp;nbsp;date formats. What is your result supposed to look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Replace the yymmdd6. in the code below with the format you want though it really sounds like you want yymmdd6.&lt;/P&gt;
&lt;P&gt;PUT(DATEFIELD,yymmdd6.) as col_b&lt;/P&gt;
&lt;P&gt;would display 17Jan2017 as 170117&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_;

   x='17Jan2017'd;
   put x= yymmdd6.;
run;&lt;/PRE&gt;</description>
    <pubDate>Tue, 11 Apr 2017 22:57:42 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-04-11T22:57:42Z</dc:date>
    <item>
      <title>date to character format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349238#M273546</link>
      <description>&lt;P&gt;okay, i am using sas eg and i have an input file.&amp;nbsp; the field i am importing is in YYMMDD format currently from a flat txt file.&amp;nbsp; so what i need to do is put this field into both a date format and a character formatted field (YYMMDD6.) but i cannot seem to get it to come out right.&amp;nbsp; i import it as a date field and then try...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select DATEFIELD, DATEFIELD format=MMDDYY10. AS col_a , PUT(DATEFIELD,8.) as col_b&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;from DATATABLE;&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;however the output is...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATEFIELD&amp;nbsp; col_a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; col_b&lt;/P&gt;&lt;P&gt;170117&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01/17/2017&amp;nbsp;&amp;nbsp;&amp;nbsp; 20836&lt;/P&gt;&lt;P&gt;170201&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02/01/2017&amp;nbsp;&amp;nbsp;&amp;nbsp; 20851&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;col b is left aligned like a text but it is clearly changing the original data to another, probably the translated date.&amp;nbsp; but i need it output 170117 as characters, as is with no translation.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 19:51:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349238#M273546</guid>
      <dc:creator>me55</dc:creator>
      <dc:date>2017-04-11T19:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: date to character format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349247#M273547</link>
      <description>&lt;P&gt;The value&amp;nbsp;&lt;SPAN&gt;20836 is Jan 17, 2017, so my question is what the format is on&amp;nbsp;DATEFIELD?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 20:03:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349247#M273547</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-04-11T20:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: date to character format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349252#M273548</link>
      <description>&lt;P&gt;This&lt;/P&gt;
&lt;P&gt;PUT(DATEFIELD,8.) as col_b&lt;/P&gt;
&lt;P&gt;tells SAS to display the value as 8 digits.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PUT(DATEFIELD,yymmdd6.) as col_b&lt;/P&gt;
&lt;P&gt;would display as date in that format&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 20:12:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349252#M273548</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-11T20:12:17Z</dc:date>
    </item>
    <item>
      <title>Re: date to character format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349253#M273549</link>
      <description>&lt;P&gt;Try this....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;proc sql;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;select DATEFIELD, DATEFIELD format=MMDDYY10. AS col_a , PUT(DATEFIELD,ddmmyyn6.) as col_b&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;from DATATABLE;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 20:15:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349253#M273549</guid>
      <dc:creator>Tosin</dc:creator>
      <dc:date>2017-04-11T20:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: date to character format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349267#M273550</link>
      <description>&lt;P&gt;yeah but i dont need a date in return.&amp;nbsp; i need col_b to output the date but in character format.&amp;nbsp; DATEFIELD is imported using YYMMDD6. format.&amp;nbsp; with that field i need it to populate two columns, one is a date field in a different format.&amp;nbsp; that is not an issue however the other column i need it to populate is a character field.&amp;nbsp; so it need to change format or maybe change the way it is imported i guess i am not sure...but i need that one column after imported to fill two columns, a date and a text column.&amp;nbsp; so far every way i have tried to convert that date to char ends up with a sas converted date i believe.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 21:06:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349267#M273550</guid>
      <dc:creator>me55</dc:creator>
      <dc:date>2017-04-11T21:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: date to character format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349286#M273551</link>
      <description>&lt;P&gt;There are about 30 different SAS supplied&amp;nbsp;date formats. What is your result supposed to look like?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Replace the yymmdd6. in the code below with the format you want though it really sounds like you want yymmdd6.&lt;/P&gt;
&lt;P&gt;PUT(DATEFIELD,yymmdd6.) as col_b&lt;/P&gt;
&lt;P&gt;would display 17Jan2017 as 170117&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_;

   x='17Jan2017'd;
   put x= yymmdd6.;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Apr 2017 22:57:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349286#M273551</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-11T22:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: date to character format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349431#M273552</link>
      <description>&lt;P&gt;yes, i can use put to make it look like i want it to but the problem is a date formatted data will not feed into a character formatted column.&amp;nbsp; so it puts me in the same spot which is virtually the same code i was running above.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i will try it again just in case i did something wrong but they key is I NEED THE DATA TO FEED INTO A CHARACTER FORMATTED COLUMN and a date one.&amp;nbsp; i clearly already have the date part solved it is the character part i am having issues with.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 13:06:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349431#M273552</guid>
      <dc:creator>me55</dc:creator>
      <dc:date>2017-04-12T13:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: date to character format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349488#M273553</link>
      <description>&lt;P&gt;okay, so after researching a bit more, i found that YYMMDD10. and YYMMDD6. are in character format so those two would be able to go from a date field directly into a character field.&amp;nbsp; since i have them in ...8. format, i guess that is not character format?!&amp;nbsp; but alas, i got it working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks everyone for the help on this.&amp;nbsp; i appreciate it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 15:31:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349488#M273553</guid>
      <dc:creator>me55</dc:creator>
      <dc:date>2017-04-12T15:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: date to character format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349520#M273554</link>
      <description>Not just those two&lt;BR /&gt;All formats return character strings through a PUT() function</description>
      <pubDate>Wed, 12 Apr 2017 16:38:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349520#M273554</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2017-04-12T16:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: date to character format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349522#M273555</link>
      <description>It is just that 8. returns the underlying number which is the way SAS stores numeric values. Only with a date format will you get that date string</description>
      <pubDate>Wed, 12 Apr 2017 16:39:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349522#M273555</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2017-04-12T16:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: date to character format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349525#M273556</link>
      <description>&lt;P&gt;that is the perfect response i was looking for.&amp;nbsp; i understand completely now how that works and why it was not working before.&amp;nbsp; so the function PUT converts the date to characters not that format as a character format.&amp;nbsp; so when i was importing it as YYMMDD6.,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it wouldnt go into the field because it was just a date and if i take even that and use PUT(DATEFIELD,YYMMDD6.) that would allow it to go into a character field.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i really appreciate that repsonse peter_c.&amp;nbsp; now i really understand it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 16:47:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-to-character-format/m-p/349525#M273556</guid>
      <dc:creator>me55</dc:creator>
      <dc:date>2017-04-12T16:47:10Z</dc:date>
    </item>
  </channel>
</rss>

