<?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: Inserting yesterday's date with proc sql insert into in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Inserting-yesterday-s-date-with-proc-sql-insert-into/m-p/270889#M53876</link>
    <description>&lt;P&gt;It works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;insert into ora.fraud_handshaking_log&lt;BR /&gt;set OWNER='SAS',&lt;BR /&gt;TABLE_NAME='ABT_FINAL',&lt;BR /&gt;&lt;U&gt;&lt;STRONG&gt;DATA_TIME = intnx('dtday', datetime("&amp;amp;SYSDATE"d), -1),&lt;/STRONG&gt;&lt;/U&gt;&lt;BR /&gt;PERIOD='DAILY',&lt;BR /&gt;SAS_PROCESS_START_TIME=%sysfunc(datetime()),&lt;BR /&gt;SAS_LOAD_TYPE='TRUNCATE/INSERT',&lt;BR /&gt;SAS_STATUS = 0;&lt;BR /&gt;quit;&lt;/P&gt;</description>
    <pubDate>Tue, 17 May 2016 06:48:15 GMT</pubDate>
    <dc:creator>dincoo</dc:creator>
    <dc:date>2016-05-17T06:48:15Z</dc:date>
    <item>
      <title>Inserting yesterday's date with proc sql insert into</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-yesterday-s-date-with-proc-sql-insert-into/m-p/270042#M53586</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to insert yesterday's date into a table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;insert into x&lt;BR /&gt;(OWNER,&lt;BR /&gt;TABLE_NAME,&lt;BR /&gt;DATA_TIME,&lt;BR /&gt;PERIOD,&lt;BR /&gt;SAS_PROCESS_START_TIME,&lt;BR /&gt;SAS_LOAD_TYPE)&lt;BR /&gt;values&lt;BR /&gt;('SAS',&lt;BR /&gt;'ABT_TABLES',&lt;BR /&gt;%sysfunc(intnx(day,%sysfunc(date()), -1),date9.), &amp;nbsp; &amp;nbsp; /* YESTERDAY*/&lt;BR /&gt;'DAILY',&lt;BR /&gt;%sysfunc(datetime()),&lt;BR /&gt;'TRUNCATE/INSERT'&lt;BR /&gt;);&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But there is an error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;24 proc sql;&lt;BR /&gt;25 insert into x&lt;BR /&gt;26 (OWNER,&lt;BR /&gt;27 TABLE_NAME,&lt;BR /&gt;28 DATA_TIME,&lt;BR /&gt;29 PERIOD,&lt;BR /&gt;30 SAS_PROCESS_START_TIME,&lt;BR /&gt;31 SAS_LOAD_TYPE)&lt;BR /&gt;32 values&lt;BR /&gt;33 ('SAS',&lt;BR /&gt;34 'ABT_TABLES',&lt;BR /&gt;35 %sysfunc(intnx(day,%sysfunc(date()), -1),date9.),&lt;BR /&gt;NOTE: Line generated by the macro function "SYSFUNC".&lt;BR /&gt;35 11MAY2016&lt;BR /&gt;_______&lt;BR /&gt;22&lt;BR /&gt;202&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant, a datetime constant,&lt;BR /&gt;a missing value, ), +, ',', -, MISSING, NULL, USER.&lt;/P&gt;&lt;P&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thnaks,&lt;/P&gt;&lt;P&gt;Onur&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 13:22:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-yesterday-s-date-with-proc-sql-insert-into/m-p/270042#M53586</guid>
      <dc:creator>dincoo</dc:creator>
      <dc:date>2016-05-12T13:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting yesterday's date with proc sql insert into</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-yesterday-s-date-with-proc-sql-insert-into/m-p/270055#M53596</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After tidying up the code a bit, I see that the %sysfunc() returns a datetime value, but this is not valid to insert into a numeric. &amp;nbsp;I assume that data_time is a date field, and sas_process_start_time is a datetime field. &amp;nbsp;You will note that I quote the text (macro is always text!) from the sysfunc, and then put dt after it to mean the result is a datateime literal.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
  insert into X (OWNER,TABLE_NAME,DATA_TIME,PERIOD,SAS_PROCESS_START_TIME,SAS_LOAD_TYPE)
  values ('SAS','ABT_TABLES',today()-1,'DAILY',"%sysfunc(datetime())"dt,'TRUNCATE/INSERT');
quit;&lt;/PRE&gt;
&lt;P&gt;Try that, if you still get problems, also post the code that creates the initial table. &amp;nbsp;Is there any reason why you would need to do this as an insert, you would find a simple datastep is easier especially for many rows or more complicated processing.&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 13:43:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-yesterday-s-date-with-proc-sql-insert-into/m-p/270055#M53596</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-05-12T13:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting yesterday's date with proc sql insert into</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-yesterday-s-date-with-proc-sql-insert-into/m-p/270061#M53600</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your answer, there is a scheduled code which runs every night. My purpose is: if there is an error when running the code I am going to insert that the scheduled code gets an error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;22 GOPTIONS ACCESSIBLE;&lt;BR /&gt;23 proc sql;&lt;BR /&gt;24 insert into X (OWNER,TABLE_NAME,DATA_TIME,PERIOD,SAS_PROCESS_START_TIME,SAS_LOAD_TYPE)&lt;BR /&gt;25 values ('SAS','ABT_TABLES',today()-1,'DAILY',"%sysfunc(datetime())"dt,'TRUNCATE/INSERT');&lt;BR /&gt;_____&lt;BR /&gt;22&lt;BR /&gt;202&lt;BR /&gt;ERROR: Invalid date/time/datetime constant "1778690767.80049"dt.&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant, a datetime constant,&lt;BR /&gt;a missing value, ), +, ',', -, MISSING, NULL, USER.&lt;/P&gt;&lt;P&gt;ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;X Table variables type:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;Type&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;OWNER&lt;/TD&gt;&lt;TD&gt;Character&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;TABLE_NAME&lt;/TD&gt;&lt;TD&gt;Character&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;DATA_TIME&lt;/TD&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;PERIOD&lt;/TD&gt;&lt;TD&gt;Character&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;AKSIGORTA_STATUS&lt;/TD&gt;&lt;TD&gt;Numeric&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SAS_STATUS&lt;/TD&gt;&lt;TD&gt;Numeric&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;AKSIGORTA_PROCESS_START_TIME&lt;/TD&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;AKSIGORTA_PROCESS_END_TIME&lt;/TD&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SAS_PROCESS_START_TIME&lt;/TD&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SAS_PROCESS_END_TIME&lt;/TD&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SAS_LOAD_TYPE&lt;/TD&gt;&lt;TD&gt;Character&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;AKSIGORTA_LOAD_TYPE&lt;/TD&gt;&lt;TD&gt;Character&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;AKSIGORTA_COUNT&lt;/TD&gt;&lt;TD&gt;Numeric&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;SAS_COUNT&lt;/TD&gt;&lt;TD&gt;Numeric&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 12 May 2016 13:52:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-yesterday-s-date-with-proc-sql-insert-into/m-p/270061#M53600</guid>
      <dc:creator>dincoo</dc:creator>
      <dc:date>2016-05-12T13:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting yesterday's date with proc sql insert into</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-yesterday-s-date-with-proc-sql-insert-into/m-p/270067#M53604</link>
      <description>&lt;P&gt;Sorry, your losing me here, is this something whih is happening on the database? &amp;nbsp;If so what does SAS have to do with this, run your updates in the database? &amp;nbsp;This is what is really confusing me is this jumping back and forth between technologies here, database and SAS. &amp;nbsp;If its a SAS dataset then:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;values ('SAS','ABT_TABLES',today()-1,'DAILY',today()&lt;/SPAN&gt;&lt;SPAN&gt;,'TRUNCATE/INSERT');&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Should work.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 14:01:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-yesterday-s-date-with-proc-sql-insert-into/m-p/270067#M53604</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-05-12T14:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting yesterday's date with proc sql insert into</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-yesterday-s-date-with-proc-sql-insert-into/m-p/270872#M53869</link>
      <description>&lt;P&gt;Thanks for the details but I just only want to use proc sql insert into to&amp;nbsp;write yesterday's date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2016 04:40:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-yesterday-s-date-with-proc-sql-insert-into/m-p/270872#M53869</guid>
      <dc:creator>dincoo</dc:creator>
      <dc:date>2016-05-17T04:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting yesterday's date with proc sql insert into</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inserting-yesterday-s-date-with-proc-sql-insert-into/m-p/270889#M53876</link>
      <description>&lt;P&gt;It works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;insert into ora.fraud_handshaking_log&lt;BR /&gt;set OWNER='SAS',&lt;BR /&gt;TABLE_NAME='ABT_FINAL',&lt;BR /&gt;&lt;U&gt;&lt;STRONG&gt;DATA_TIME = intnx('dtday', datetime("&amp;amp;SYSDATE"d), -1),&lt;/STRONG&gt;&lt;/U&gt;&lt;BR /&gt;PERIOD='DAILY',&lt;BR /&gt;SAS_PROCESS_START_TIME=%sysfunc(datetime()),&lt;BR /&gt;SAS_LOAD_TYPE='TRUNCATE/INSERT',&lt;BR /&gt;SAS_STATUS = 0;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2016 06:48:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inserting-yesterday-s-date-with-proc-sql-insert-into/m-p/270889#M53876</guid>
      <dc:creator>dincoo</dc:creator>
      <dc:date>2016-05-17T06:48:15Z</dc:date>
    </item>
  </channel>
</rss>

