<?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: forcing date into character in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/forcing-date-into-character/m-p/438976#M13538</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;char_date = put(originalDate, mmddyy10.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS does not have a format for DD-MON-YYYY if that's the format you want, I would suggest creating your own format and combining it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Either way your code could be simplified to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;char_date = CATX('-', put(day(originalDate), z2.), put(originalDate, monname3.), put(year(originalDate), 4.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/168242"&gt;@tellmeaboutityo&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to force a date variable into a character variable.&amp;nbsp; This doesn't work, which makes me sad:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want; set have;&lt;/P&gt;
&lt;P&gt;format originaldate mmddyyd10.;&lt;BR /&gt;length chardate $9;&lt;BR /&gt;chardate = originaldate;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below does work, but there has to be an easier way?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want; set have;&lt;/P&gt;
&lt;P&gt;format originaldate mmddyyd10.;&lt;/P&gt;
&lt;P&gt;originaldate = datepart(degconfdate);&lt;BR /&gt;year = year(originaldate);&lt;BR /&gt;day = day(originaldate);&lt;BR /&gt;month = month(originaldate);&lt;/P&gt;
&lt;P&gt;if month = 1 then month_c = '-Jan-';&lt;BR /&gt;if month = 2 then month _c = '-Feb-';&lt;BR /&gt;if month = 3 then month _c = '-Mar-';&lt;BR /&gt;if month = 4 then month _c = '-Apr-';&lt;BR /&gt;if month = 5 then month _c = '-May-';&lt;BR /&gt;if month = 6 then month _c = '-Jun-';&lt;BR /&gt;if month = 7 then month _c = '-Jul-';&lt;BR /&gt;if month = 8 then month _c = '-Aug-';&lt;BR /&gt;if month = 9 then month _c = '-Sep-';&lt;BR /&gt;if month = 10 then month _c = '-Oct-';&lt;BR /&gt;if month = 11 then month _c = '-Nov-';&lt;BR /&gt;if month = 12 then month _c = '-Dec-';&lt;BR /&gt;length chardate $9;&lt;/P&gt;
&lt;P&gt;chardate = catt(day, month_c, year);&lt;/P&gt;
&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Feb 2018 16:07:01 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-02-21T16:07:01Z</dc:date>
    <item>
      <title>forcing date into character</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/forcing-date-into-character/m-p/438974#M13537</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to force a date variable into a character variable.&amp;nbsp; This doesn't work, which makes me sad:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want; set have;&lt;/P&gt;&lt;P&gt;format originaldate mmddyyd10.;&lt;BR /&gt;length chardate $9;&lt;BR /&gt;chardate = originaldate;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below does work, but there has to be an easier way?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want; set have;&lt;/P&gt;&lt;P&gt;format originaldate mmddyyd10.;&lt;/P&gt;&lt;P&gt;originaldate = datepart(originaldate);&lt;BR /&gt;year = year(originaldate);&lt;BR /&gt;day = day(originaldate);&lt;BR /&gt;month = month(originaldate);&lt;/P&gt;&lt;P&gt;length month_c $5;&lt;/P&gt;&lt;P&gt;if month = 1 then month_c = '-Jan-';&lt;BR /&gt;if month = 2 then month _c = '-Feb-';&lt;BR /&gt;if month = 3 then month _c = '-Mar-';&lt;BR /&gt;if month = 4 then month _c = '-Apr-';&lt;BR /&gt;if month = 5 then month _c = '-May-';&lt;BR /&gt;if month = 6 then month _c = '-Jun-';&lt;BR /&gt;if month = 7 then month _c = '-Jul-';&lt;BR /&gt;if month = 8 then month _c = '-Aug-';&lt;BR /&gt;if month = 9 then month _c = '-Sep-';&lt;BR /&gt;if month = 10 then month _c = '-Oct-';&lt;BR /&gt;if month = 11 then month _c = '-Nov-';&lt;BR /&gt;if month = 12 then month _c = '-Dec-';&lt;BR /&gt;length chardate $9;&lt;/P&gt;&lt;P&gt;chardate = catt(day, month_c, year);&lt;/P&gt;&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2018 16:07:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/forcing-date-into-character/m-p/438974#M13537</guid>
      <dc:creator>tellmeaboutityo</dc:creator>
      <dc:date>2018-02-21T16:07:21Z</dc:date>
    </item>
    <item>
      <title>Re: forcing date into character</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/forcing-date-into-character/m-p/438976#M13538</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;char_date = put(originalDate, mmddyy10.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS does not have a format for DD-MON-YYYY if that's the format you want, I would suggest creating your own format and combining it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Either way your code could be simplified to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;char_date = CATX('-', put(day(originalDate), z2.), put(originalDate, monname3.), put(year(originalDate), 4.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/168242"&gt;@tellmeaboutityo&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to force a date variable into a character variable.&amp;nbsp; This doesn't work, which makes me sad:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want; set have;&lt;/P&gt;
&lt;P&gt;format originaldate mmddyyd10.;&lt;BR /&gt;length chardate $9;&lt;BR /&gt;chardate = originaldate;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below does work, but there has to be an easier way?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want; set have;&lt;/P&gt;
&lt;P&gt;format originaldate mmddyyd10.;&lt;/P&gt;
&lt;P&gt;originaldate = datepart(degconfdate);&lt;BR /&gt;year = year(originaldate);&lt;BR /&gt;day = day(originaldate);&lt;BR /&gt;month = month(originaldate);&lt;/P&gt;
&lt;P&gt;if month = 1 then month_c = '-Jan-';&lt;BR /&gt;if month = 2 then month _c = '-Feb-';&lt;BR /&gt;if month = 3 then month _c = '-Mar-';&lt;BR /&gt;if month = 4 then month _c = '-Apr-';&lt;BR /&gt;if month = 5 then month _c = '-May-';&lt;BR /&gt;if month = 6 then month _c = '-Jun-';&lt;BR /&gt;if month = 7 then month _c = '-Jul-';&lt;BR /&gt;if month = 8 then month _c = '-Aug-';&lt;BR /&gt;if month = 9 then month _c = '-Sep-';&lt;BR /&gt;if month = 10 then month _c = '-Oct-';&lt;BR /&gt;if month = 11 then month _c = '-Nov-';&lt;BR /&gt;if month = 12 then month _c = '-Dec-';&lt;BR /&gt;length chardate $9;&lt;/P&gt;
&lt;P&gt;chardate = catt(day, month_c, year);&lt;/P&gt;
&lt;P&gt;run;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2018 16:07:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/forcing-date-into-character/m-p/438976#M13538</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-21T16:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: forcing date into character</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/forcing-date-into-character/m-p/438979#M13539</link>
      <description>&lt;P&gt;You didn't actually specify what you want the result to look like.&amp;nbsp; Here's a simple conversion:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;chardate = put( datepart(degconfdate), date9.);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you really want dashes in between, switch to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;chardate = put( datepart(degconfdate), date11.);&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2018 16:13:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/forcing-date-into-character/m-p/438979#M13539</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-21T16:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: forcing date into character</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/forcing-date-into-character/m-p/438981#M13540</link>
      <description>&lt;P&gt;Reeza-- If you keep being so awesome, I'm going to owe you a martini!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Astounding-- I didn't specify a result because I'm outputting multiple formats and wanted a general solution.&amp;nbsp; Thanks for the help, though!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2018 16:21:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/forcing-date-into-character/m-p/438981#M13540</guid>
      <dc:creator>tellmeaboutityo</dc:creator>
      <dc:date>2018-02-21T16:21:34Z</dc:date>
    </item>
  </channel>
</rss>

