<?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 ddmmmyyyy character date to date9. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-ddmmmyyyy-character-date-to-date9/m-p/331219#M74411</link>
    <description>Thank you. One more question regarding this issue. Does the variable name need to be different in the following statement: date=input(char_date,date9.); Can you keep the same variable name but permanently change the variable type from character to numeric? I noticed that once I changed the variable name then it worked.</description>
    <pubDate>Thu, 09 Feb 2017 16:19:33 GMT</pubDate>
    <dc:creator>PaulaC</dc:creator>
    <dc:date>2017-02-09T16:19:33Z</dc:date>
    <item>
      <title>Converting ddmmmyyyy character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-ddmmmyyyy-character-date-to-date9/m-p/331157#M74383</link>
      <description>&lt;P&gt;&lt;SPAN&gt;My current date character value is stored as ddmmmyyyy so I used date9. when changing it to the numeric value. The problem is that when I look at my data set the value for that variable is the SAS date. I tried using "format date date9.;" to convert the SAS date to Date 9. but I am getting the following error message: ERROR 48-59: The format $DATE was not found or could not be loaded.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What am I doing wrong? Thanks.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;format date date9.;&lt;BR /&gt;datel=input(date,date9.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;totday=intck('day',daterand,date);&lt;/SPAN&gt;&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;example of data:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Date &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Subject # &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Visit # &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Randomization date&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;01May1996 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15Jan1996&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;25July1996 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15Jan1996&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;15Aug1995 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20Mar1995&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 14:07:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-ddmmmyyyy-character-date-to-date9/m-p/331157#M74383</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-02-09T14:07:42Z</dc:date>
    </item>
    <item>
      <title>Re: Converting ddmmmyyyy character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-ddmmmyyyy-character-date-to-date9/m-p/331163#M74387</link>
      <description>&lt;P&gt;Post example test data as a datastep, and show what the output should look like. &amp;nbsp;If you have a character field, then you can't just format it to date as it will still be a chacter variable. &amp;nbsp;Do something like:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have (rename=(date=char_date));
  date=input(char_date,date9.);
  format date date9.;
run;&lt;/PRE&gt;
&lt;P&gt;So your creating a numeric variable to hold a numeric date.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 14:23:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-ddmmmyyyy-character-date-to-date9/m-p/331163#M74387</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-02-09T14:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: Converting ddmmmyyyy character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-ddmmmyyyy-character-date-to-date9/m-p/331185#M74395</link>
      <description>Thank you for your help. Doesn't the input function convert it to a numeric date?&lt;BR /&gt;I will most definitely try to post my example data as a datastep. I always seem to run into errors when I do that especially with dates.</description>
      <pubDate>Thu, 09 Feb 2017 15:13:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-ddmmmyyyy-character-date-to-date9/m-p/331185#M74395</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-02-09T15:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: Converting ddmmmyyyy character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-ddmmmyyyy-character-date-to-date9/m-p/331192#M74400</link>
      <description>&lt;P&gt;Well, the input function returns a number - which is the number of days since a certain date which is how SAS keeps dates. &amp;nbsp;If you have:&lt;BR /&gt;&amp;lt;character variable&amp;gt;=112344;&lt;/P&gt;
&lt;P&gt;format &amp;lt;character variable&amp;gt; &amp;lt;numeric format&amp;gt;;&lt;/P&gt;
&lt;P&gt;Its not going to work. &amp;nbsp;So you want the variable that recieves the number from the input() function to be number, so it can be formatted using the numeric format date9.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should help on the dataset:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 15:31:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-ddmmmyyyy-character-date-to-date9/m-p/331192#M74400</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-02-09T15:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Converting ddmmmyyyy character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-ddmmmyyyy-character-date-to-date9/m-p/331212#M74408</link>
      <description>&lt;P&gt;You posted this code:&lt;/P&gt;
&lt;PRE&gt;datel=input(date,date9.);

totday=intck('day',daterand,date); 
&lt;/PRE&gt;
&lt;P&gt;BY ANY chance did you try to use the DATEL(numeric) variable instead of DATE(character) in the INTCK call&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 16:07:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-ddmmmyyyy-character-date-to-date9/m-p/331212#M74408</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-02-09T16:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Converting ddmmmyyyy character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-ddmmmyyyy-character-date-to-date9/m-p/331219#M74411</link>
      <description>Thank you. One more question regarding this issue. Does the variable name need to be different in the following statement: date=input(char_date,date9.); Can you keep the same variable name but permanently change the variable type from character to numeric? I noticed that once I changed the variable name then it worked.</description>
      <pubDate>Thu, 09 Feb 2017 16:19:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-ddmmmyyyy-character-date-to-date9/m-p/331219#M74411</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-02-09T16:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: Converting ddmmmyyyy character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-ddmmmyyyy-character-date-to-date9/m-p/331224#M74412</link>
      <description>&lt;P&gt;In my example:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have (rename=(date=char_date));
  date=input(char_date,date9.);
  format date date9.;
run;&lt;/PRE&gt;
&lt;P&gt;I first rename the variable you already have - in the set statement - so no variable named date is in the data at that moment. &amp;nbsp;Now when I use the assingment date=, this creates a new variable called date - which as I have not specified a length/type, defaults to numeric 8. &amp;nbsp;Into this new variable I then put the result of the input() function, and its this new variable which is formatted. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 16:27:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-ddmmmyyyy-character-date-to-date9/m-p/331224#M74412</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-02-09T16:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: Converting ddmmmyyyy character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-ddmmmyyyy-character-date-to-date9/m-p/331255#M74423</link>
      <description>that was a typo. my input statement code was: date=input(date,date9.); but I got an error message when used format date date9. When I changed the input to daten=input(date,date9.) and format daten date9. then the error message disappeared and a new variable daten was created.&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Feb 2017 17:36:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-ddmmmyyyy-character-date-to-date9/m-p/331255#M74423</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-02-09T17:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: Converting ddmmmyyyy character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-ddmmmyyyy-character-date-to-date9/m-p/331269#M74432</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/107488"&gt;@PaulaC&lt;/a&gt; wrote:&lt;BR /&gt;that was a typo. my input statement code was: date=input(date,date9.); but I got an error message when used format date date9. When I changed the input to daten=input(date,date9.) and format daten date9. then the error message disappeared and a new variable daten was created.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;To minimize typo issues, and especially when you run code with an error, go to the SAS log and copy the code with the error and diagnostic messages. Then paste into a code box using the {i} icon. The code box will retain the formatting of the orginal log and the error message often has an _ indicating the exact place SAS encountered the trigger for the message. The forum main text boxes actually reformat your pasted text and loses information like where SAS placed that underscore.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 18:15:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-ddmmmyyyy-character-date-to-date9/m-p/331269#M74432</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-02-09T18:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: Converting ddmmmyyyy character date to date9.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-ddmmmyyyy-character-date-to-date9/m-p/331279#M74436</link>
      <description>ok. thank you for the tip. I did not realize that.&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Feb 2017 18:41:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-ddmmmyyyy-character-date-to-date9/m-p/331279#M74436</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-02-09T18:41:29Z</dc:date>
    </item>
  </channel>
</rss>

