<?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 Cannot insert today() via PROC SQL ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Cannot-insert-today-via-PROC-SQL/m-p/99730#M20979</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;I have a SAS data set with two variables:&amp;nbsp; load_dt, a date value formatted as mmddyy10, and n_recs_sas, a numeric value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to use PROC SQL to insert a new record.&amp;nbsp; load_dt must have the current date.&amp;nbsp; I'm loading n_recs_sas from a macro variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The query is not letting me use the today() or date() function in the VALUES clause.&amp;nbsp; The error message is explicit, but can anyone tell me &lt;SPAN style="text-decoration: underline;"&gt;why&lt;/SPAN&gt;?&amp;nbsp; I know there are a couple work arounds but I'd like to understand what's going on here.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;714 proc sql;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;715 insert into test2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;716 (load_dt, n_recs_sas)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;717 values (&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;718 today() as load_dt format=mmddyy10.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;76&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant, a datetime constant,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a missing value, +, -, MISSING, NULL, USER.&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;P&gt;&lt;/P&gt;&lt;P&gt;719 , input(put("&amp;amp;_numRecsInFinalDSN",$8.),8.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;720 );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;721 quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 07 Jun 2013 18:49:06 GMT</pubDate>
    <dc:creator>bentleyj1</dc:creator>
    <dc:date>2013-06-07T18:49:06Z</dc:date>
    <item>
      <title>Cannot insert today() via PROC SQL ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cannot-insert-today-via-PROC-SQL/m-p/99730#M20979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;I have a SAS data set with two variables:&amp;nbsp; load_dt, a date value formatted as mmddyy10, and n_recs_sas, a numeric value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to use PROC SQL to insert a new record.&amp;nbsp; load_dt must have the current date.&amp;nbsp; I'm loading n_recs_sas from a macro variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The query is not letting me use the today() or date() function in the VALUES clause.&amp;nbsp; The error message is explicit, but can anyone tell me &lt;SPAN style="text-decoration: underline;"&gt;why&lt;/SPAN&gt;?&amp;nbsp; I know there are a couple work arounds but I'd like to understand what's going on here.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;714 proc sql;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;715 insert into test2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;716 (load_dt, n_recs_sas)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;717 values (&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;718 today() as load_dt format=mmddyy10.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;22&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;76&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant, a datetime constant,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a missing value, +, -, MISSING, NULL, USER.&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;P&gt;&lt;/P&gt;&lt;P&gt;719 , input(put("&amp;amp;_numRecsInFinalDSN",$8.),8.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;720 );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;721 quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jun 2013 18:49:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cannot-insert-today-via-PROC-SQL/m-p/99730#M20979</guid>
      <dc:creator>bentleyj1</dc:creator>
      <dc:date>2013-06-07T18:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot insert today() via PROC SQL ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cannot-insert-today-via-PROC-SQL/m-p/99731#M20980</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;VALUES wants constants, not functions or queries. You can use %SYSFUNC() to call TODAY() function and have result appear as if you typed it.&amp;nbsp; The same actually applies to your macro variable.&amp;nbsp; So your statement becomes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; insert into test2 (load_dt , n_recs_sas)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; values (%sysfunc(today()),&amp;amp;_numRecsInFinalDSN)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jun 2013 19:10:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cannot-insert-today-via-PROC-SQL/m-p/99731#M20980</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-06-07T19:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot insert today() via PROC SQL ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cannot-insert-today-via-PROC-SQL/m-p/99732#M20981</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another alternative is to use the "set" syntax of the insert statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt; insert into test2 set load_dt = today();&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In addition, I don't think there are any circumstances in which the insert statement allows "as" or "format=" as you have in your OP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jun 2013 19:18:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cannot-insert-today-via-PROC-SQL/m-p/99732#M20981</guid>
      <dc:creator>KarlK</dc:creator>
      <dc:date>2013-06-07T19:18:07Z</dc:date>
    </item>
  </channel>
</rss>

