<?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: Convert String to SAS Datetime using DS2 in SAS ESP procedural/compute window in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Convert-String-to-SAS-Datetime-using-DS2-in-SAS-ESP-procedural/m-p/555384#M445</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/203934"&gt;@arkam&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;It is type string and this is the format which is displayed in SAS stream viewer&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;10/31/2011 13:34&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I want both the date and the time to aggregate on.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't have a lot of experience with DS2 and no data sources to actually connect to but from the documentation:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;H1 class="xis-title"&gt;How to Specify Informats in DS2&lt;/H1&gt;
&lt;DIV class="xis-topicContent" id="n1vlisl6t5wutyn1tjdlsiybe4m8"&gt;
&lt;DIV class="xis-paragraph" id="p0mhd9k7q9zu1tn1pk9izfb1np0x"&gt;In DS2, specify informats as an attribute in the HAVING clause of the DECLARE statement. For example, in the following statement, the column &lt;SPAN class="xis-userSuppliedValue"&gt;y&lt;/SPAN&gt; is declared with the IEEE8.2 format and the BITS5.2 informat.
&lt;PRE class="xis-codeFragment"&gt;dcl double y having format ieee8.2 informat bits5.2;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So that is why I think you get the message out input not wanting any parameters and that just applying the informat as above does the conversion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest getting a datetime value from the string and then pulling the bits out using the DATEPART and TIMPART functions once you have the datetime variable populated.&lt;/P&gt;
&lt;P&gt;The following creates a SAS datetime value from that sort of string value so is the likely informat to specify on the DCL statement.&lt;/P&gt;
&lt;PRE&gt;data example;
  x='10/31/2011 13:34';
  y= input(x, anydtdtm.);
  format y datetime18.;
run;&lt;/PRE&gt;
&lt;P&gt;So using the&lt;/P&gt;</description>
    <pubDate>Wed, 01 May 2019 15:50:15 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-05-01T15:50:15Z</dc:date>
    <item>
      <title>Convert String to SAS Datetime using DS2 in SAS ESP procedural/compute window</title>
      <link>https://communities.sas.com/t5/Developers/Convert-String-to-SAS-Datetime-using-DS2-in-SAS-ESP-procedural/m-p/554812#M442</link>
      <description>&lt;P&gt;I am new to DS2. I am trying to convert string "10/31/2011 1:34:00 PM", passed through "time" variable, to SAS date value to be used in SAS ESP.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However when I run it in ESP I get the error below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"load project failed: tradesDemo, the input function requires 0 parameter(s)"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ds2_options cdump;&lt;BR /&gt;data esp.out;&lt;BR /&gt;dcl timestamp datetime;&lt;BR /&gt;method run();&lt;BR /&gt;set esp.in;&lt;BR /&gt;datetime = input(time, mmddyy10.);&lt;BR /&gt;format datetime mmddyy10.;&lt;BR /&gt;end;&lt;BR /&gt;enddata;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 18:36:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Convert-String-to-SAS-Datetime-using-DS2-in-SAS-ESP-procedural/m-p/554812#M442</guid>
      <dc:creator>arkam</dc:creator>
      <dc:date>2019-04-29T18:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: Convert String to SAS Datetime using DS2 in SAS ESP procedural/compute window</title>
      <link>https://communities.sas.com/t5/Developers/Convert-String-to-SAS-Datetime-using-DS2-in-SAS-ESP-procedural/m-p/554822#M443</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/203934"&gt;@arkam&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am new to DS2. I am trying to convert string "10/31/2011 1:34:00 PM", passed through "time" variable, to SAS date value to be used in SAS ESP.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However when I run it in ESP I get the error below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;"load project failed: tradesDemo, the input function requires 0 parameter(s)"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ds2_options cdump;&lt;BR /&gt;data esp.out;&lt;BR /&gt;dcl timestamp datetime;&lt;BR /&gt;method run();&lt;BR /&gt;set esp.in;&lt;BR /&gt;datetime = input(time, mmddyy10.);&lt;BR /&gt;format datetime mmddyy10.;&lt;BR /&gt;end;&lt;BR /&gt;enddata;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you do not attempt any operation on the variable time what type is the resulting variable and what format does it have? Not what it looks like in the source data system but as reported by SAS tools on the result data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In general the INPUT function takes a character value. If time is actually numeric then that is one possible problem.&lt;/P&gt;
&lt;P&gt;I will also say that apparently wanting only the date part of value but calling it "datetime" is likely&amp;nbsp;to be&amp;nbsp;a source of confusion in the future.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 19:25:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Convert-String-to-SAS-Datetime-using-DS2-in-SAS-ESP-procedural/m-p/554822#M443</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-29T19:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: Convert String to SAS Datetime using DS2 in SAS ESP procedural/compute window</title>
      <link>https://communities.sas.com/t5/Developers/Convert-String-to-SAS-Datetime-using-DS2-in-SAS-ESP-procedural/m-p/555128#M444</link>
      <description>&lt;P&gt;It is type string and this is the format which is displayed in SAS stream viewer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;10/31/2011 13:34&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want both the date and the time to aggregate on.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Apr 2019 16:56:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Convert-String-to-SAS-Datetime-using-DS2-in-SAS-ESP-procedural/m-p/555128#M444</guid>
      <dc:creator>arkam</dc:creator>
      <dc:date>2019-04-30T16:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: Convert String to SAS Datetime using DS2 in SAS ESP procedural/compute window</title>
      <link>https://communities.sas.com/t5/Developers/Convert-String-to-SAS-Datetime-using-DS2-in-SAS-ESP-procedural/m-p/555384#M445</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/203934"&gt;@arkam&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;It is type string and this is the format which is displayed in SAS stream viewer&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;10/31/2011 13:34&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I want both the date and the time to aggregate on.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't have a lot of experience with DS2 and no data sources to actually connect to but from the documentation:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;H1 class="xis-title"&gt;How to Specify Informats in DS2&lt;/H1&gt;
&lt;DIV class="xis-topicContent" id="n1vlisl6t5wutyn1tjdlsiybe4m8"&gt;
&lt;DIV class="xis-paragraph" id="p0mhd9k7q9zu1tn1pk9izfb1np0x"&gt;In DS2, specify informats as an attribute in the HAVING clause of the DECLARE statement. For example, in the following statement, the column &lt;SPAN class="xis-userSuppliedValue"&gt;y&lt;/SPAN&gt; is declared with the IEEE8.2 format and the BITS5.2 informat.
&lt;PRE class="xis-codeFragment"&gt;dcl double y having format ieee8.2 informat bits5.2;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So that is why I think you get the message out input not wanting any parameters and that just applying the informat as above does the conversion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest getting a datetime value from the string and then pulling the bits out using the DATEPART and TIMPART functions once you have the datetime variable populated.&lt;/P&gt;
&lt;P&gt;The following creates a SAS datetime value from that sort of string value so is the likely informat to specify on the DCL statement.&lt;/P&gt;
&lt;PRE&gt;data example;
  x='10/31/2011 13:34';
  y= input(x, anydtdtm.);
  format y datetime18.;
run;&lt;/PRE&gt;
&lt;P&gt;So using the&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 15:50:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Convert-String-to-SAS-Datetime-using-DS2-in-SAS-ESP-procedural/m-p/555384#M445</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-01T15:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: Convert String to SAS Datetime using DS2 in SAS ESP procedural/compute window</title>
      <link>https://communities.sas.com/t5/Developers/Convert-String-to-SAS-Datetime-using-DS2-in-SAS-ESP-procedural/m-p/555393#M446</link>
      <description>&lt;P&gt;Does the INPUT function work in DS2?&amp;nbsp; It doesn't work with %SYSFUNC().&amp;nbsp; There you need to use INPUTN() or INPUTC() depending on the target value type.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;datetime = inputN(time, 'mmddyy10.');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 May 2019 16:14:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Convert-String-to-SAS-Datetime-using-DS2-in-SAS-ESP-procedural/m-p/555393#M446</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-01T16:14:35Z</dc:date>
    </item>
  </channel>
</rss>

