<?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 sybase string column into SAS Date in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-sybase-string-column-into-SAS-Date/m-p/202983#M4490</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks I got this figured out with the help from stachoverflow.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the solution &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0 0 1em; font-size: 15px; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #ffffff;"&gt;proc sql noprint;&lt;/P&gt;&lt;P style="margin: 0 0 1em; font-size: 15px; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #ffffff;"&gt;SELECT&lt;/P&gt;&lt;P style="margin: 0 0 1em; font-size: 15px; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #ffffff;"&gt;select max(input(PROPERTY_VAL, anydtdtm24.)) format=datetime22.3 into :last_updt_tmsp from sybase_lib.prop_vals where property_key='last.update.date';&lt;/P&gt;&lt;P style="margin: 0 0 1em; font-size: 15px; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #ffffff;"&gt;quit;&lt;/P&gt;&lt;P style="margin: 0 0 1em; font-size: 15px; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #ffffff;"&gt;format &amp;amp;last_updt_tmsp. DATETIME18.;&lt;/P&gt;&lt;P style="margin: 0 0 1em; font-size: 15px; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #ffffff;"&gt;data &lt;EM&gt;null&lt;/EM&gt;;&lt;/P&gt;&lt;P style="margin: 0 0 1em; font-size: 15px; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #ffffff;"&gt;call symput('lst_cre_dttm',"'"||"&amp;amp;last_updt_tmsp."||"'dt");&lt;/P&gt;&lt;P style="margin: 0 0 1em; font-size: 15px; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;P style="margin: 0 0 1em; font-size: 15px; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #ffffff;"&gt;%put lst_cre_dttm=&amp;amp;lst_cre_dttm&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 26 Apr 2015 02:20:45 GMT</pubDate>
    <dc:creator>etl_tool</dc:creator>
    <dc:date>2015-04-26T02:20:45Z</dc:date>
    <item>
      <title>Convert sybase string column into SAS Date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-sybase-string-column-into-SAS-Date/m-p/202978#M4485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need your help. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to convert a string column which is in sybase in the below format into SAS date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The sybase table has string values like this &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2015-04-23 04:04:46.517&lt;/P&gt;&lt;P&gt;2015-04-22 04:04:35.162&lt;/P&gt;&lt;P&gt;2015-04-21 04:04:43.646&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to get the max of these values and store it in a max_tmsp variable and get the records where last_updt_tmsp &amp;gt; max_tmsp. I wrote a precode before the job starts but it is not working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;I referred to the below link and tried to write some code.&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;A href="http://studysas.blogspot.com/2010/09/how-to-convert-character-string-date-to.html" title="http://studysas.blogspot.com/2010/09/how-to-convert-character-string-date-to.html"&gt;How to convert the datetime character string to SAS datetime value? (ANYDTDTM and MDYAMPM formats) | StudySAS Blog&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All this code is in Precode before the job starts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;SELECT &lt;/P&gt;&lt;P&gt;select max(input(PROPERTY_VAL, MDYAMPMw.d)) into :last_updt_tmsp &lt;/P&gt;&lt;P&gt;from sybase_lib.prop_vals&amp;nbsp; where property_key='last.update.date';&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;format &amp;amp;last_updt_tmsp. DATETIME18.;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;call symput('lst_cre_dttm',"'"||"&amp;amp;last_updt_tmsp."||"'dt");&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%put lst_cre_dttm=&amp;amp;lst_cre_dttm&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 02:27:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Convert-sybase-string-column-into-SAS-Date/m-p/202978#M4485</guid>
      <dc:creator>etl_tool</dc:creator>
      <dc:date>2015-04-24T02:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: Convert sybase string column into SAS Date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-sybase-string-column-into-SAS-Date/m-p/202979#M4486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You really should be getting errors and post the errors.&lt;/P&gt;&lt;P&gt;The following line most likely should be in a dataset. But macro variables do not have formats, they are all string.&lt;/P&gt;&lt;P&gt;format &amp;amp;last_updt_tmsp. DATETIME18.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the data you are trying to convert is yyyy-mm-dd hh:mm:ss.ff then you do not want to use&amp;nbsp; MDYAMPMw.d as that reads data as mmddyyyy hh:mm:ss AM/PM.&lt;/P&gt;&lt;P&gt;You want the informat&amp;nbsp; ymddttm25. The value of max however is going to be a number such as 1521285787.40000.&lt;/P&gt;&lt;P&gt;If you want the macro variable to look like&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 21APR2015:04:04:44 then you need something like&lt;/P&gt;&lt;P&gt;select put((max(input(PROPERTY_VAL, MDYAMPMw.d))),datetime25.) into :last_updt_tmsp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However since it looks like you want to make a datetime literal with the data _null_ step you should:&lt;/P&gt;&lt;P&gt;Not worry about the "format" of the macro variable if you are planning in using it in code later.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 15:43:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Convert-sybase-string-column-into-SAS-Date/m-p/202979#M4486</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-04-24T15:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: Convert sybase string column into SAS Date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-sybase-string-column-into-SAS-Date/m-p/202980#M4487</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Ballardw. I'll try, however I am having difficulty where the job sometimes does not read the precode and the variable is not getting read.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 16:09:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Convert-sybase-string-column-into-SAS-Date/m-p/202980#M4487</guid>
      <dc:creator>etl_tool</dc:creator>
      <dc:date>2015-04-24T16:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: Convert sybase string column into SAS Date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-sybase-string-column-into-SAS-Date/m-p/202981#M4488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Getting this error in the log &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a format name, ?.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 18:03:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Convert-sybase-string-column-into-SAS-Date/m-p/202981#M4488</guid>
      <dc:creator>etl_tool</dc:creator>
      <dc:date>2015-04-24T18:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: Convert sybase string column into SAS Date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-sybase-string-column-into-SAS-Date/m-p/202982#M4489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Show the submitted code with the error messages.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Apr 2015 19:08:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Convert-sybase-string-column-into-SAS-Date/m-p/202982#M4489</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-04-24T19:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: Convert sybase string column into SAS Date</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-sybase-string-column-into-SAS-Date/m-p/202983#M4490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks I got this figured out with the help from stachoverflow.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the solution &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0 0 1em; font-size: 15px; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #ffffff;"&gt;proc sql noprint;&lt;/P&gt;&lt;P style="margin: 0 0 1em; font-size: 15px; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #ffffff;"&gt;SELECT&lt;/P&gt;&lt;P style="margin: 0 0 1em; font-size: 15px; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #ffffff;"&gt;select max(input(PROPERTY_VAL, anydtdtm24.)) format=datetime22.3 into :last_updt_tmsp from sybase_lib.prop_vals where property_key='last.update.date';&lt;/P&gt;&lt;P style="margin: 0 0 1em; font-size: 15px; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #ffffff;"&gt;quit;&lt;/P&gt;&lt;P style="margin: 0 0 1em; font-size: 15px; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #ffffff;"&gt;format &amp;amp;last_updt_tmsp. DATETIME18.;&lt;/P&gt;&lt;P style="margin: 0 0 1em; font-size: 15px; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #ffffff;"&gt;data &lt;EM&gt;null&lt;/EM&gt;;&lt;/P&gt;&lt;P style="margin: 0 0 1em; font-size: 15px; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #ffffff;"&gt;call symput('lst_cre_dttm',"'"||"&amp;amp;last_updt_tmsp."||"'dt");&lt;/P&gt;&lt;P style="margin: 0 0 1em; font-size: 15px; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;P style="margin: 0 0 1em; font-size: 15px; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #ffffff;"&gt;%put lst_cre_dttm=&amp;amp;lst_cre_dttm&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 26 Apr 2015 02:20:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Convert-sybase-string-column-into-SAS-Date/m-p/202983#M4490</guid>
      <dc:creator>etl_tool</dc:creator>
      <dc:date>2015-04-26T02:20:45Z</dc:date>
    </item>
  </channel>
</rss>

