<?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: How can I convert the char to num for time because I need to calculate them in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-the-char-to-num-for-time-because-I-need-to/m-p/923467#M363553</link>
    <description>Thank you so much!</description>
    <pubDate>Mon, 08 Apr 2024 19:07:52 GMT</pubDate>
    <dc:creator>SerenaJJ</dc:creator>
    <dc:date>2024-04-08T19:07:52Z</dc:date>
    <item>
      <title>How can I convert the char to num for time because I need to calculate them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-the-char-to-num-for-time-because-I-need-to/m-p/921859#M363021</link>
      <description>&lt;P&gt;Hi, I have time1:&amp;nbsp;2022-02-02T13:28&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; time2:&amp;nbsp;2022-02-02T12:28&amp;nbsp;&lt;/P&gt;&lt;P&gt;They are both char vaules. Because I need to do the calculation&amp;nbsp;if time1 &amp;gt; = time2 then&lt;/P&gt;&lt;P&gt;&amp;nbsp; time3= time1 - time2 + 1, so how can I convert them to num value and then do the calculation.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 20:10:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-the-char-to-num-for-time-because-I-need-to/m-p/921859#M363021</guid>
      <dc:creator>SerenaJJ</dc:creator>
      <dc:date>2024-03-26T20:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert the char to num for time because I need to calculate them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-the-char-to-num-for-time-because-I-need-to/m-p/921861#M363023</link>
      <description>&lt;P&gt;First, are you sure these are char? You need to find if the output from PROC CONTENTS says these are char. Sometimes you can't simply tell by looking at the values. Can you tell us what PROC CONTENTS says?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 20:15:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-the-char-to-num-for-time-because-I-need-to/m-p/921861#M363023</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-03-26T20:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert the char to num for time because I need to calculate them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-the-char-to-num-for-time-because-I-need-to/m-p/921864#M363024</link>
      <description>&lt;P&gt;Run a DATA step like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have (rename=(time1=_time1 time2=_time2));
format time1 time2 e8601dt19.;
time1 = input(_time1,e8601dt16.);
time2 = input(_time2,e8601dt16.);
drop _time1 _time2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Untested, posted from my tablet.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 20:19:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-the-char-to-num-for-time-because-I-need-to/m-p/921864#M363024</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-03-26T20:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert the char to num for time because I need to calculate them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-the-char-to-num-for-time-because-I-need-to/m-p/921880#M363036</link>
      <description>&lt;P&gt;You should show use exactly what you expect the result of time3= time1 - time2 + 1 would look like expressed as a time on the clock.&lt;/P&gt;
&lt;P&gt;The values you show will most easily turn into a SAS datetime value which will have units of seconds.&lt;/P&gt;
&lt;P&gt;So the Time3 value using the values shown would end up with a numeric value of 3601 which would represent 1:00:01 or one hour and 1 second.&lt;/P&gt;
&lt;P&gt;If you want the number of HOURS you would would use something like&lt;/P&gt;
&lt;PRE&gt;hours = intck('hour',time2,time1);&lt;/PRE&gt;
&lt;P&gt;The INTCK function counts intervals. So could request seconds, hours, and since your values are DATETIME, could ask for day ('DTDAY' as the interval), month ('DTMONTH' as the interval) or a number of other intervals.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt; has a PDF with much information about dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 22:38:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-the-char-to-num-for-time-because-I-need-to/m-p/921880#M363036</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-03-26T22:38:12Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert the char to num for time because I need to calculate them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-the-char-to-num-for-time-because-I-need-to/m-p/921896#M363049</link>
      <description>Thank you so much for your reply. I checked the output, there are days for the variable time3.&lt;BR /&gt;</description>
      <pubDate>Wed, 27 Mar 2024 01:55:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-the-char-to-num-for-time-because-I-need-to/m-p/921896#M363049</guid>
      <dc:creator>SerenaJJ</dc:creator>
      <dc:date>2024-03-27T01:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert the char to num for time because I need to calculate them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-the-char-to-num-for-time-because-I-need-to/m-p/921902#M363055</link>
      <description>Thank you so much for your reply. Yes, these are char after checking.</description>
      <pubDate>Wed, 27 Mar 2024 02:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-the-char-to-num-for-time-because-I-need-to/m-p/921902#M363055</guid>
      <dc:creator>SerenaJJ</dc:creator>
      <dc:date>2024-03-27T02:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert the char to num for time because I need to calculate them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-the-char-to-num-for-time-because-I-need-to/m-p/921903#M363056</link>
      <description>&lt;P&gt;If you want the difference in DAYS then convert the strings into DATE values. Those are stored in DAYS.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;time3=input(time1,yymmdd10.)-input(time2,yymmdd10.)+1;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Mar 2024 03:20:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-the-char-to-num-for-time-because-I-need-to/m-p/921903#M363056</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-03-27T03:20:49Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert the char to num for time because I need to calculate them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-the-char-to-num-for-time-because-I-need-to/m-p/923464#M363551</link>
      <description>&lt;P&gt;Thank you all for your help!!&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2024 19:07:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-the-char-to-num-for-time-because-I-need-to/m-p/923464#M363551</guid>
      <dc:creator>SerenaJJ</dc:creator>
      <dc:date>2024-04-08T19:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert the char to num for time because I need to calculate them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-the-char-to-num-for-time-because-I-need-to/m-p/923466#M363552</link>
      <description>Thank you so much!&lt;BR /&gt;</description>
      <pubDate>Mon, 08 Apr 2024 19:07:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-the-char-to-num-for-time-because-I-need-to/m-p/923466#M363552</guid>
      <dc:creator>SerenaJJ</dc:creator>
      <dc:date>2024-04-08T19:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert the char to num for time because I need to calculate them</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-the-char-to-num-for-time-because-I-need-to/m-p/923467#M363553</link>
      <description>Thank you so much!</description>
      <pubDate>Mon, 08 Apr 2024 19:07:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-the-char-to-num-for-time-because-I-need-to/m-p/923467#M363553</guid>
      <dc:creator>SerenaJJ</dc:creator>
      <dc:date>2024-04-08T19:07:52Z</dc:date>
    </item>
  </channel>
</rss>

