<?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: Current timestamp equivalent function in SAS via Implicit passthrough in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786584#M251167</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;I want to switch to implicit pass through as in the later stage we will use SAS macro variable in the where clause and expand the filter. May I request you to provide me the solution using&amp;nbsp;implicit pass through?&lt;/P&gt;</description>
    <pubDate>Sat, 18 Dec 2021 07:16:31 GMT</pubDate>
    <dc:creator>David_Billa</dc:creator>
    <dc:date>2021-12-18T07:16:31Z</dc:date>
    <item>
      <title>Current timestamp equivalent function in SAS via Implicit passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786581#M251164</link>
      <description>&lt;P&gt;I want to convert the following SQL query to proc SQL implicit pass through. But I'm not certain how to identify the equivalent current_timestamp function in SAS. When I tried with SAS datetime() function, it is yielding the value with numbers. Should I need to use to Format (e.g. Datetime26.7) to display the timestamp value? If yes, may I know where should I use the Format in Proc SQL implicit passthrough code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SQL query which works in SQL server:&lt;/P&gt;
&lt;PRE&gt;update Employee set STAT_DESC='FINISHED', END_TMST=current_timestamp where act_ind='Y'&lt;/PRE&gt;
&lt;P&gt;SAS code:&lt;/P&gt;
&lt;PRE&gt;proc sql; 
update sql_lib.Employee set OBJ_STAT_DESC="FINISHED", END_TMST=&amp;lt;looking for valid function and format&amp;gt; where act_ind="Y";
quit;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Dec 2021 06:53:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786581#M251164</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-12-18T06:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: Current timestamp equivalent function in SAS via Implicit passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786582#M251165</link>
      <description>&lt;P&gt;Why do you want to switch to implicit passthru? If you stick to explicit passthru you don't need to change anything:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  connect to SQLSRVR using SQL_LIB;
  execute (update Employee set STAT_DESC='FINISHED', END_TMST=current_timestamp where act_ind='Y') by SQLSRVR;
quit; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Dec 2021 07:03:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786582#M251165</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-12-18T07:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: Current timestamp equivalent function in SAS via Implicit passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786583#M251166</link>
      <description>&lt;P&gt;To help someone with more of a clue about this than I do you might make sure that the specific database and connection method are mentioned. I believe that the ODBC vs SAS/Access for XXX may have different restrictions even though talking to the same data base. The connection may also make a difference on how dates/times or datetime values need to pass.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Dec 2021 07:06:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786583#M251166</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-12-18T07:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: Current timestamp equivalent function in SAS via Implicit passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786584#M251167</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;I want to switch to implicit pass through as in the later stage we will use SAS macro variable in the where clause and expand the filter. May I request you to provide me the solution using&amp;nbsp;implicit pass through?&lt;/P&gt;</description>
      <pubDate>Sat, 18 Dec 2021 07:16:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786584#M251167</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-12-18T07:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: Current timestamp equivalent function in SAS via Implicit passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786585#M251168</link>
      <description>&lt;P&gt;First, check how the timestamp has to be supplied as a &lt;EM&gt;literal&lt;/EM&gt; in the target database. Then build that literal in SAS for use in the pass-through.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Dec 2021 07:43:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786585#M251168</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-12-18T07:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: Current timestamp equivalent function in SAS via Implicit passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786587#M251169</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;I want to switch to implicit pass through as in the later stage we will use SAS macro variable in the where clause and expand the filter. May I request you to provide me the solution using&amp;nbsp;implicit pass through?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I can't really help on this. No access to, or experience with, any of the DB connections.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Dec 2021 07:48:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786587#M251169</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-12-18T07:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: Current timestamp equivalent function in SAS via Implicit passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786588#M251170</link>
      <description>Could you please point me to one simple example?</description>
      <pubDate>Sat, 18 Dec 2021 07:58:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786588#M251170</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-12-18T07:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: Current timestamp equivalent function in SAS via Implicit passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786589#M251171</link>
      <description>&lt;P&gt;I'm sorry but since you haven't posted your complete requirement, I've given you the best solution for the part you did post. If you post your complete requirement then we will have a better chance of providing the best solution.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Dec 2021 08:10:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786589#M251171</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-12-18T08:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Current timestamp equivalent function in SAS via Implicit passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786590#M251172</link>
      <description>Can we use the SAS macro variable after the execute statement?&lt;BR /&gt;&lt;BR /&gt;E.g. execute (update.....where act_ind='&amp;amp;y.')&lt;BR /&gt;</description>
      <pubDate>Sat, 18 Dec 2021 08:59:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786590#M251172</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-12-18T08:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: Current timestamp equivalent function in SAS via Implicit passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786591#M251173</link>
      <description>&lt;P&gt;You can use macro variables in every piece of code that SAS handles, but you must use them correctly.&lt;/P&gt;
&lt;P&gt;Since macro variables are not resolved within single quotes, you must make the single quotes part of the macro variable when you create it, and then call it without any quotes.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Dec 2021 09:55:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786591#M251173</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-12-18T09:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: Current timestamp equivalent function in SAS via Implicit passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786625#M251194</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp; - Yes of course as long as you use double quotes to resolve the macro variable as explained by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;execute (update.....where act_ind="&amp;amp;y.")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the database you are using objects to the double quotes then use this instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;execute (update.....where act_ind= %str(%')&amp;amp;y.%str(%'))&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Dec 2021 22:07:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786625#M251194</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-12-18T22:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: Current timestamp equivalent function in SAS via Implicit passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786627#M251196</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS macro variables will resolve BEFORE the SQL executes - and this applies for implicit and explicit SQL. For this reason you can also use a SAS macro variable within explicit SQL - you just need to populate it with a value appropriate the the explicit SQL syntax.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first thing you have to figure out is how the string you pass to SQL Server needs to look like so it gets interpreted as a datetime value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't have access to a SQL server right now but Google tells me that something like the following should work:&lt;BR /&gt;&lt;SPAN class="hljs-keyword"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;CONVERT&lt;/SPAN&gt;&lt;SPAN&gt;(DATETIME, &lt;/SPAN&gt;&lt;SPAN class="hljs-string"&gt;'2019-09-25 12:11:09.555'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that's true then all you need to do is populate a macro variable with:&amp;nbsp;&lt;SPAN class="hljs-string"&gt;'yyyy-mm-dd hh:mm:ss.fff'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Below sample doing this using datetime() - but you could of course use any other SAS datetime value (=value that is the count of seconds since 1Jan1960).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let ts_string=%sysfunc(datetime(),E8601DT23.3);
%let ts_string=%sysfunc(translate(&amp;amp;ts_string,' ','T'));
%let ts_string=%unquote(%nrbquote('&amp;amp;ts_string'));
%put &amp;amp;=ts_string;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And now you could use this string in your pass-through SQL&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;update Employee set STAT_DESC='FINISHED', END_TMST=convert(datetime, &amp;amp;ts_string) where act_ind='Y'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Dec 2021 00:04:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786627#M251196</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-12-19T00:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: Current timestamp equivalent function in SAS via Implicit passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786628#M251197</link>
      <description>&lt;P&gt;What is the source of the DATETIME value?&amp;nbsp; Do you want it from the system clock? On which system? Your SAS system? Or the database server?&amp;nbsp; If the later then find out what syntax you need to use in that database's version of SQL to use the system clock.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are going to reference a variable like in your example then they should not be any change to the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if you want to use a literal datetime value that you have calculated in SAS then it depends on what the remote database wants as the style for specifying datetime values.&amp;nbsp; I quick google for SAS SQL SERVER found:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-ver15" target="_blank"&gt;https://docs.microsoft.com/en-us/sql/t-sql/data-types/datetime-transact-sql?view=sql-server-ver15&lt;/A&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;The advantage in using the ISO 8601 format is that it is an international standard with unambiguous specification. Also, this format isn't affected by the SET DATEFORMAT or&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://docs.microsoft.com/en-us/sql/t-sql/statements/set-language-transact-sql?view=sql-server-ver15" data-linktype="relative-path" target="_blank"&gt;SET LANGUAGE&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;setting.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So use the E8601DT format to generate the datetime literal.&amp;nbsp; Make sure to include the single quotes in the value.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  call symputx('CURRENT_TIMESTAMP',quote(put(datetime(),e8601dt.),"'"));
run;
%put &amp;amp;=CURRENT_TIMESTAMP;

proc sql;
connect using sqllib;
execute by sqllib
(update Employee
  set STAT_DESC='FINISHED'
    , END_TMST=&amp;amp;current_timestamp 
  where act_ind='Y'
);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 19 Dec 2021 01:11:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786628#M251197</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-19T01:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: Current timestamp equivalent function in SAS via Implicit passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786632#M251201</link>
      <description>Thank you. How to use this approach using Libname statement (Implicit Pass through)?</description>
      <pubDate>Sun, 19 Dec 2021 05:08:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786632#M251201</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-12-19T05:08:42Z</dc:date>
    </item>
    <item>
      <title>Re: Current timestamp equivalent function in SAS via Implicit passthrough</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786673#M251212</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you. How to use this approach using Libname statement (Implicit Pass through)?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;With SAS code you can use the DATETIME() function directly.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; 
update sql_lib.Employee
  set OBJ_STAT_DESC="FINISHED"
     , END_TMST=datettime() 
  where act_ind="Y"
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or the actual number of seconds.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let current_timestamp=%sysfunc(datetime());
proc sql; 
update sql_lib.Employee
  set OBJ_STAT_DESC="FINISHED"
     , END_TMST=&amp;amp;current_timestamp
  where act_ind="Y"
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or if you want to make a datetime literal use the DATETIME format to convert the number of seconds into a string that the DATETIME informat can read enclosed in quotes with DT after it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let current_timestamp="%sysfunc(datetime(),datetime19.)"dt;
proc sql; 
update sql_lib.Employee
  set OBJ_STAT_DESC="FINISHED"
     , END_TMST=&amp;amp;current_timestamp
  where act_ind="Y"
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Dec 2021 19:45:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Current-timestamp-equivalent-function-in-SAS-via-Implicit/m-p/786673#M251212</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-19T19:45:48Z</dc:date>
    </item>
  </channel>
</rss>

