<?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: Changing date column from CHAR to NUM in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Changing-date-column-from-CHAR-to-NUM/m-p/777605#M247418</link>
    <description>&lt;P&gt;1) you can't change the type of an existing variable&lt;/P&gt;
&lt;P&gt;2) you created a new variable &lt;STRONG&gt;test_date&lt;/STRONG&gt; that should be numeric and display in the Date9. format. That is the one to look at as your code did not even attempt to change Accurate_Episode_Date.&lt;/P&gt;</description>
    <pubDate>Sun, 31 Oct 2021 21:51:14 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-10-31T21:51:14Z</dc:date>
    <item>
      <title>Changing date column from CHAR to NUM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-date-column-from-CHAR-to-NUM/m-p/777603#M247416</link>
      <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am having issues changing my DATE column from a CHAR to a NUM so that I can do a join with another table.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code runs, however when I check the properties, the "accurate_episode_date"'s property is still CHAR.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;data main2; set covid.covid;&lt;/P&gt;
&lt;P class="p1"&gt;format test_date mmddyy10.;&lt;/P&gt;
&lt;P class="p1"&gt;test_date = input(Accurate_Episode_Date,date9.);&lt;/P&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;run;&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sun, 31 Oct 2021 21:20:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-date-column-from-CHAR-to-NUM/m-p/777603#M247416</guid>
      <dc:creator>JibJam221</dc:creator>
      <dc:date>2021-10-31T21:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Changing date column from CHAR to NUM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-date-column-from-CHAR-to-NUM/m-p/777605#M247418</link>
      <description>&lt;P&gt;1) you can't change the type of an existing variable&lt;/P&gt;
&lt;P&gt;2) you created a new variable &lt;STRONG&gt;test_date&lt;/STRONG&gt; that should be numeric and display in the Date9. format. That is the one to look at as your code did not even attempt to change Accurate_Episode_Date.&lt;/P&gt;</description>
      <pubDate>Sun, 31 Oct 2021 21:51:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-date-column-from-CHAR-to-NUM/m-p/777605#M247418</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-31T21:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: Changing date column from CHAR to NUM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-date-column-from-CHAR-to-NUM/m-p/777609#M247420</link>
      <description>Sorry I meant to say that test_date didnt change to a NUM variable. Any suggestions on how to make test_date a NUM var?</description>
      <pubDate>Sun, 31 Oct 2021 22:13:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-date-column-from-CHAR-to-NUM/m-p/777609#M247420</guid>
      <dc:creator>JibJam221</dc:creator>
      <dc:date>2021-10-31T22:13:09Z</dc:date>
    </item>
    <item>
      <title>Re: Changing date column from CHAR to NUM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-date-column-from-CHAR-to-NUM/m-p/777613#M247421</link>
      <description>&lt;P&gt;Please post the complete log of that step.&lt;/P&gt;</description>
      <pubDate>Sun, 31 Oct 2021 23:09:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-date-column-from-CHAR-to-NUM/m-p/777613#M247421</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-31T23:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: Changing date column from CHAR to NUM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-date-column-from-CHAR-to-NUM/m-p/777615#M247423</link>
      <description>The format in the INPUT needs to match how the variable currently looks. Since you've said DATE9 that means that your variable looks like 31OCT2021 right now?&lt;BR /&gt;</description>
      <pubDate>Sun, 31 Oct 2021 23:25:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-date-column-from-CHAR-to-NUM/m-p/777615#M247423</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-31T23:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: Changing date column from CHAR to NUM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Changing-date-column-from-CHAR-to-NUM/m-p/777688#M247454</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/207689"&gt;@JibJam221&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Sorry I meant to say that test_date didnt change to a NUM variable. Any suggestions on how to make test_date a NUM var?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You cannot change the type of an existing variable. So if TEST_DATE already appeared as a character variable in your source dataset then just trying to attach a numeric format to it or assign a numeric value to it would not change how it was already defined.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check that TEST_DATE does not already exist on COVID.COVID.&amp;nbsp; If it does then you can use DROP= or RENAME= dataset option to get it out of the way so you can use TEST_DATE as the name of your NEW variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data main2; 
  set covid.covid (drop=test_date);
  format test_date mmddyy10.;
  test_date = input(Accurate_Episode_Date,date9.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Nov 2021 14:34:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Changing-date-column-from-CHAR-to-NUM/m-p/777688#M247454</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-01T14:34:17Z</dc:date>
    </item>
  </channel>
</rss>

