<?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: In a proc sql statement how to convert character date and time to date and time in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/In-a-proc-sql-statement-how-to-convert-character-date-and-time/m-p/949415#M45451</link>
    <description>&lt;P&gt;15:22&lt;/P&gt;</description>
    <pubDate>Tue, 29 Oct 2024 21:05:01 GMT</pubDate>
    <dc:creator>alepage</dc:creator>
    <dc:date>2024-10-29T21:05:01Z</dc:date>
    <item>
      <title>In a proc sql statement how to convert character date and time to date and time</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/In-a-proc-sql-statement-how-to-convert-character-date-and-time/m-p/949405#M45448</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's my proc SQL&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table sasfile as
select 	distinct owner,
        group,
		permissions,
		cfname,
		fname,
		cr_dt,
		time, 
		sum(filesize) format =  SIZEKMG6.2 as totalfsize
		
from sasfiles2
group by fname;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How to convert the cr_dt from character to date format like yyyy-mm-dd and time like 15h22&lt;/P&gt;
&lt;P&gt;fname cr_dt time totalfsize&lt;BR /&gt;be_auto_prmnov2020 2020-11-26 00:48 1.39GB&lt;BR /&gt;be_auto_prmnov2020 2020-12-02 15:22 1.39GB&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 19:45:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/In-a-proc-sql-statement-how-to-convert-character-date-and-time/m-p/949405#M45448</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2024-10-29T19:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: In a proc sql statement how to convert character date and time to date and time</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/In-a-proc-sql-statement-how-to-convert-character-date-and-time/m-p/949406#M45449</link>
      <description>&lt;P&gt;The same way you would when not using SQL,&amp;nbsp; with the INPUT() function.&lt;/P&gt;
&lt;P&gt;If there is an INFORMAT that can read the strings you have then you could convert them into a DATETIME value using the INPUT() function.&lt;/P&gt;
&lt;P&gt;If not then use SCAN() or some other tool to split the string into the date and time parts and use informats that can convert those strings into date or time values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please share some example values of the strings you have.&amp;nbsp; Remember to use the INSERT CODE or INSERT SAS CODE buttons to get a pop-up window where you an paste and/or edit the text you want to share.&amp;nbsp; That will prevent the webpage from reflowing the text into paragraphs.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 19:51:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/In-a-proc-sql-statement-how-to-convert-character-date-and-time/m-p/949406#M45449</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-10-29T19:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: In a proc sql statement how to convert character date and time to date and time</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/In-a-proc-sql-statement-how-to-convert-character-date-and-time/m-p/949412#M45450</link>
      <description>&lt;P&gt;I don't recognize a date and time that looks like 15h22, what date and time is that?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 20:51:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/In-a-proc-sql-statement-how-to-convert-character-date-and-time/m-p/949412#M45450</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-10-29T20:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: In a proc sql statement how to convert character date and time to date and time</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/In-a-proc-sql-statement-how-to-convert-character-date-and-time/m-p/949415#M45451</link>
      <description>&lt;P&gt;15:22&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 21:05:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/In-a-proc-sql-statement-how-to-convert-character-date-and-time/m-p/949415#M45451</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2024-10-29T21:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: In a proc sql statement how to convert character date and time to date and time</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/In-a-proc-sql-statement-how-to-convert-character-date-and-time/m-p/949428#M45452</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76331"&gt;@alepage&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;15:22&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;15 minutes and 22 seconds?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;15 hours and 22 minutes?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 22:18:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/In-a-proc-sql-statement-how-to-convert-character-date-and-time/m-p/949428#M45452</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-10-29T22:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: In a proc sql statement how to convert character date and time to date and time</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/In-a-proc-sql-statement-how-to-convert-character-date-and-time/m-p/949430#M45453</link>
      <description>&lt;P&gt;Is below what you're after?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  var='be_auto_prmnov2020 2020-11-26 00:48 1.39GB'; output;
  var='be_auto_prmnov2020 2020-12-02 15:22 1.39GB'; output;
run;

proc sql;
  select 
    var
    ,scan(var,2,' ') as dt_string
    ,scan(var,3,' ') as tm_string
    ,input(catx('T',scan(var,2,' '),scan(var,3,' ')),e8601dt.) as dttm format=datetime.
  from have
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1730241275908.png" style="width: 759px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101869i6D839F430AE9FE67/image-dimensions/759x107?v=v2" width="759" height="107" role="button" title="Patrick_0-1730241275908.png" alt="Patrick_0-1730241275908.png" /&gt;&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 22:34:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/In-a-proc-sql-statement-how-to-convert-character-date-and-time/m-p/949430#M45453</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-10-29T22:34:50Z</dc:date>
    </item>
  </channel>
</rss>

