<?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 will not change to Character in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-will-not-change-to-Character/m-p/873514#M345139</link>
    <description>&lt;P&gt;If you want a character date there is no need to convert it to a SAS date:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  x = '2018-10-01 00:00:00:00';
  zz = compress(substr(x, 1, 10), '-');
  put _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 03 May 2023 02:25:47 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2023-05-03T02:25:47Z</dc:date>
    <item>
      <title>Date will not change to Character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-will-not-change-to-Character/m-p/873511#M345137</link>
      <description>&lt;PRE&gt;data have;
x='2018-10-01 00:00:00:00';
y=input(x,anydtdtm.);

z=datepart(y);
put z;
format z YYMMDDN8.;
zz=put(z,YYMMDDN8.);
run;&lt;/PRE&gt;
&lt;P&gt;In this example zz is converted to a character from a date format.&amp;nbsp; In my actual data when I use the above routine it stays as a date.&amp;nbsp; It will not change from a date to a character.&amp;nbsp; Is there some other way to convert from date to character?&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2023 01:57:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-will-not-change-to-Character/m-p/873511#M345137</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2023-05-03T01:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: Date will not change to Character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-will-not-change-to-Character/m-p/873514#M345139</link>
      <description>&lt;P&gt;If you want a character date there is no need to convert it to a SAS date:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  x = '2018-10-01 00:00:00:00';
  zz = compress(substr(x, 1, 10), '-');
  put _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 May 2023 02:25:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-will-not-change-to-Character/m-p/873514#M345139</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-05-03T02:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: Date will not change to Character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-will-not-change-to-Character/m-p/873538#M345155</link>
      <description>&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/5629"&gt;@Q1983&lt;/a&gt;&amp;nbsp;wrote:
&lt;P class="1683094581528"&gt;&amp;nbsp;&lt;/P&gt;
Is there some other way to convert from date to character?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Once a variable type is assigned to a variable name in a SAS data set then the type cannot change. If you want to reuse the variable name with a new type then you basically rename the old variable to something else (or drop from the data set) and the create a new variable of the desired name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will find lots of examples on the forum related to fixing proc import created inconsistent variable types that look something like this:&lt;/P&gt;
&lt;PRE&gt;data new;
   set old (rename=(thisvar=oldnumvar);
   thisvar = put(oldnumvar,z15.);
run;&lt;/PRE&gt;
&lt;P&gt;The format changes, or sometimes an INPUT function is called with an old character variable to create numeric.&lt;/P&gt;
&lt;P&gt;There might follow a call to Proc Datasets to delete the prior dataset "old" and rename "new" to "old" to reuse the same data set name.&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2023 06:21:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-will-not-change-to-Character/m-p/873538#M345155</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-03T06:21:51Z</dc:date>
    </item>
  </channel>
</rss>

