<?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: Support needed for converting date in text format to numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Support-needed-for-converting-date-in-text-format-to-numeric/m-p/899576#M355559</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/438118"&gt;@JohanK&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear fellow SAS users, firstly I hope to achieve the level to be able to help others but I am afraid that may take a while &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I have a dataset with dates (Date_and_time_of_assessment) in Character format like this:&amp;nbsp;2023-01-26T07:00.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to convert these values into a numeric format so I can use them for calculation purposes.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried&amp;nbsp;SAMP_DT=INPUT(Date_and_time_of_assessment, anydtdtm16.);&amp;nbsp; but that does not work.&amp;nbsp;Could anyone help me, it is much appreciated. Thanks! Johan&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I'm skeptical that this is a character "format", as there really isn't such a thing. It is either a numeric variable, or a character (or text) variable. In order to know how to handle this, we need to know from PROC CONTENTS if the variable is numeric or character. So please show us the PROC CONTENTS output for this variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Agreeing with the others, saying "that doesn't work", without additional information, has no value and doesn't lead us closer to an answer.&lt;/P&gt;</description>
    <pubDate>Sun, 22 Oct 2023 20:58:47 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-10-22T20:58:47Z</dc:date>
    <item>
      <title>Support needed for converting date in text format to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Support-needed-for-converting-date-in-text-format-to-numeric/m-p/899568#M355556</link>
      <description>&lt;P&gt;Dear fellow SAS users, firstly I hope to achieve the level to be able to help others but I am afraid that may take a while &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I have a dataset with dates (Date_and_time_of_assessment) in Character format like this:&amp;nbsp;2023-01-26T07:00.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to convert these values into a numeric format so I can use them for calculation purposes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried&amp;nbsp;SAMP_DT=INPUT(Date_and_time_of_assessment, anydtdtm16.);&amp;nbsp; but that does not work.&amp;nbsp;Could anyone help me, it is much appreciated. Thanks! Johan&lt;/P&gt;</description>
      <pubDate>Sun, 22 Oct 2023 14:49:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Support-needed-for-converting-date-in-text-format-to-numeric/m-p/899568#M355556</guid>
      <dc:creator>JohanK</dc:creator>
      <dc:date>2023-10-22T14:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: Support needed for converting date in text format to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Support-needed-for-converting-date-in-text-format-to-numeric/m-p/899569#M355557</link>
      <description>&lt;P&gt;This is the ISO 8601 extendeed format, for which SAS provides a dedicated informat:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SAMP_DT = input(Date_and_time_of_assessment,e8601dt16.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To extract the date from this datetime value, use the DATEPART function. Don't forget to attach a suitable display format to the new variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;ASTEROID-SIZED HINT:&lt;/STRONG&gt; never just say "it does not work". If there are ERRORs, WARNINGs or curious NOTEs, post the complete log of the step. If the step runs without obvious messages in the log, also post the result and describe in detail where it does not meet your expectations.&lt;/P&gt;
&lt;P&gt;"Does not work" on its own is worthy of the proverbial person who can't find their way out of a phone booth without expert help.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Oct 2023 15:29:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Support-needed-for-converting-date-in-text-format-to-numeric/m-p/899569#M355557</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-10-22T15:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Support needed for converting date in text format to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Support-needed-for-converting-date-in-text-format-to-numeric/m-p/899575#M355558</link>
      <description>&lt;P&gt;What specific calculation? No example given.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should learn to look at the SAS online help for date, time and datetime related formats and informats. There is one for that specific appearance shown below and a number of example calculations using the result.&lt;/P&gt;
&lt;PRE&gt;data example;
   string="2023-01-26T07:00";
   dt = input(string,E8601dt.);
   put dt= datetime20.;
   /* calculations: add 3 months*/
   newdt= intnx('dtmonth',dt,3,'s');
   put newdt= datetime20.;
   /* go back 5 years*/
   newdt= intnx('dtyear',dt,-5,'s');
   put newdt= datetime20.;
   /* difference in days from today*/
   dif = intck('dtday', datetime(),dt,'c');
   put dif= ;
run;&lt;/PRE&gt;</description>
      <pubDate>Sun, 22 Oct 2023 20:09:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Support-needed-for-converting-date-in-text-format-to-numeric/m-p/899575#M355558</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-10-22T20:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: Support needed for converting date in text format to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Support-needed-for-converting-date-in-text-format-to-numeric/m-p/899576#M355559</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/438118"&gt;@JohanK&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear fellow SAS users, firstly I hope to achieve the level to be able to help others but I am afraid that may take a while &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I have a dataset with dates (Date_and_time_of_assessment) in Character format like this:&amp;nbsp;2023-01-26T07:00.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to convert these values into a numeric format so I can use them for calculation purposes.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried&amp;nbsp;SAMP_DT=INPUT(Date_and_time_of_assessment, anydtdtm16.);&amp;nbsp; but that does not work.&amp;nbsp;Could anyone help me, it is much appreciated. Thanks! Johan&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I'm skeptical that this is a character "format", as there really isn't such a thing. It is either a numeric variable, or a character (or text) variable. In order to know how to handle this, we need to know from PROC CONTENTS if the variable is numeric or character. So please show us the PROC CONTENTS output for this variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Agreeing with the others, saying "that doesn't work", without additional information, has no value and doesn't lead us closer to an answer.&lt;/P&gt;</description>
      <pubDate>Sun, 22 Oct 2023 20:58:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Support-needed-for-converting-date-in-text-format-to-numeric/m-p/899576#M355559</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-22T20:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: Support needed for converting date in text format to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Support-needed-for-converting-date-in-text-format-to-numeric/m-p/899734#M355590</link>
      <description>&lt;P&gt;Thank you so much! Your solution works perfect. And sorry for my expression that 'it did not work'. I meant actually that I was not able to find the solution - there are dozens of pages online with date informats but I did not find the correct one.&amp;nbsp; With your solution I am able to substract 2 dates from eachother . Great!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2023 09:11:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Support-needed-for-converting-date-in-text-format-to-numeric/m-p/899734#M355590</guid>
      <dc:creator>JohanK</dc:creator>
      <dc:date>2023-10-24T09:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: Support needed for converting date in text format to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Support-needed-for-converting-date-in-text-format-to-numeric/m-p/899735#M355591</link>
      <description>&lt;P&gt;Thanks so much Kurt!&amp;nbsp; I got help from more users with the solution. And apologize for my wording, I meant to say that I was not able to find the solution my self instead of 'it did not work'. Appreciated&amp;nbsp;&lt;/P&gt;&lt;P&gt;greetings, Johan&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2023 09:16:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Support-needed-for-converting-date-in-text-format-to-numeric/m-p/899735#M355591</guid>
      <dc:creator>JohanK</dc:creator>
      <dc:date>2023-10-24T09:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: Support needed for converting date in text format to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Support-needed-for-converting-date-in-text-format-to-numeric/m-p/899736#M355592</link>
      <description>&lt;P&gt;Thanks for your reaction- I have a solution, this platform is great. Appreciated....&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards, Johan&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2023 09:19:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Support-needed-for-converting-date-in-text-format-to-numeric/m-p/899736#M355592</guid>
      <dc:creator>JohanK</dc:creator>
      <dc:date>2023-10-24T09:19:07Z</dc:date>
    </item>
  </channel>
</rss>

