<?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: converting date to character string keeping same format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/converting-date-to-character-string-keeping-same-format/m-p/591003#M169247</link>
    <description>&lt;P&gt;Character variables cannot have the same format as numeric variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want the character variable to appear the same as the formatted numeric variable ... why? What is the benefit of changing the variable type from numeric to character if it appears the same to us humans?&lt;/P&gt;</description>
    <pubDate>Mon, 23 Sep 2019 17:32:05 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-09-23T17:32:05Z</dc:date>
    <item>
      <title>converting date to character string keeping same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-date-to-character-string-keeping-same-format/m-p/591001#M169246</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;I have a date variable with the value as '7/30/2019 14:43' and I want to convert it into a character variable keeping the same format how do I do this? Any help will be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 17:26:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-date-to-character-string-keeping-same-format/m-p/591001#M169246</guid>
      <dc:creator>Aidaan_10</dc:creator>
      <dc:date>2019-09-23T17:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: converting date to character string keeping same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-date-to-character-string-keeping-same-format/m-p/591003#M169247</link>
      <description>&lt;P&gt;Character variables cannot have the same format as numeric variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want the character variable to appear the same as the formatted numeric variable ... why? What is the benefit of changing the variable type from numeric to character if it appears the same to us humans?&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 17:32:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-date-to-character-string-keeping-same-format/m-p/591003#M169247</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-23T17:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: converting date to character string keeping same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-date-to-character-string-keeping-same-format/m-p/591005#M169248</link>
      <description>&lt;P&gt;Look which format is used to display this&amp;nbsp;&lt;EM&gt;datetime&lt;/EM&gt; variable and use that in a put() function.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 17:32:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-date-to-character-string-keeping-same-format/m-p/591005#M169248</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-09-23T17:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: converting date to character string keeping same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-date-to-character-string-keeping-same-format/m-p/591006#M169249</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new_var = putn(old_var, vformat(old_var));&lt;BR /&gt;new_var2&amp;nbsp;=&amp;nbsp;vvalue(old_var);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Use PUTN() to convert it to a character variable.&lt;/P&gt;
&lt;P&gt;Use VFORMAT() to get the format that was displaying the variable and apply it in the conversion.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or Use VVALUE to get the formatted value into a character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: Modified as per&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;suggestions&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/174192"&gt;@Aidaan_10&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;I have a date variable with the value as '7/30/2019 14:43' and I want to convert it into a character variable keeping the same format how do I do this? Any help will be greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 20:41:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-date-to-character-string-keeping-same-format/m-p/591006#M169249</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-09-23T20:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: converting date to character string keeping same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-date-to-character-string-keeping-same-format/m-p/591009#M169250</link>
      <description>&lt;P&gt;Huh?&amp;nbsp; If it is a DATETIME value then you would need PUTN() instead of PUTC() as the N/C refers in the data type that is being formatted. The output of applying a format is always character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that you can use the VVALUE() function to see the formatted value of a variable without first having find out what format, if any, is attached to it.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 17:40:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-date-to-character-string-keeping-same-format/m-p/591009#M169250</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-09-23T17:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: converting date to character string keeping same format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/converting-date-to-character-string-keeping-same-format/m-p/591020#M169254</link>
      <description>&lt;P&gt;new_var=vvalue(old_var) worked very well. Thank you so much&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 18:34:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/converting-date-to-character-string-keeping-same-format/m-p/591020#M169254</guid>
      <dc:creator>Aidaan_10</dc:creator>
      <dc:date>2019-09-23T18:34:05Z</dc:date>
    </item>
  </channel>
</rss>

