<?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: insert date variable into table from a marcro in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/insert-date-variable-into-table-from-a-marcro/m-p/507177#M32344</link>
    <description>&lt;P&gt;Suryakrian,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your answer.&amp;nbsp; I included dt after to&amp;nbsp;use the logic with a macro.&lt;/P&gt;</description>
    <pubDate>Wed, 24 Oct 2018 14:48:06 GMT</pubDate>
    <dc:creator>DavidPhillips2</dc:creator>
    <dc:date>2018-10-24T14:48:06Z</dc:date>
    <item>
      <title>insert date variable into table from a marcro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/insert-date-variable-into-table-from-a-marcro/m-p/507138#M32335</link>
      <description>&lt;P&gt;&amp;nbsp;What is the syntax to insert a date macro variable into a table?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
select max(rundate) into: testvar SEPARATED BY '' from testtable;
create table rundatelist (
tablename varchar(100),
rundate date);

insert into rundatelist (tablename, rundate) values ('table1', to_date(&amp;amp;testvar));&amp;nbsp;&amp;nbsp;/*this line does not work*/
select * from rundatelist;
quit;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Oct 2018 13:47:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/insert-date-variable-into-table-from-a-marcro/m-p/507138#M32335</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-10-24T13:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: insert date variable into table from a marcro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/insert-date-variable-into-table-from-a-marcro/m-p/507146#M32336</link>
      <description>I think just remove the to_date() around the &amp;amp;testvar?</description>
      <pubDate>Wed, 24 Oct 2018 13:57:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/insert-date-variable-into-table-from-a-marcro/m-p/507146#M32336</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-24T13:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: insert date variable into table from a marcro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/insert-date-variable-into-table-from-a-marcro/m-p/507151#M32337</link>
      <description>&lt;P&gt;Reeza if I remove to_date(), the log shows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;24OCT2018:04:34:39&lt;BR /&gt; _______&lt;BR /&gt; 22&lt;BR /&gt; 76&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 76-322: Syntax error, statement will be ignored.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 14:03:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/insert-date-variable-into-table-from-a-marcro/m-p/507151#M32337</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-10-24T14:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: insert date variable into table from a marcro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/insert-date-variable-into-table-from-a-marcro/m-p/507153#M32338</link>
      <description>&lt;P&gt;Do you know what the correct syntax would be if you were hard-coding a value instead of referring to a macro variable?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 14:04:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/insert-date-variable-into-table-from-a-marcro/m-p/507153#M32338</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-10-24T14:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: insert date variable into table from a marcro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/insert-date-variable-into-table-from-a-marcro/m-p/507155#M32339</link>
      <description>Then wrap it in quotes and put a dt at the end. &lt;BR /&gt;&lt;BR /&gt;"&amp;amp;testvar"dt -&amp;gt; this depends on what field type you're inserting it into. For a date time use the approach above. If it's character, then drop the dt after the quotes.</description>
      <pubDate>Wed, 24 Oct 2018 14:08:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/insert-date-variable-into-table-from-a-marcro/m-p/507155#M32339</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-24T14:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: insert date variable into table from a marcro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/insert-date-variable-into-table-from-a-marcro/m-p/507157#M32341</link>
      <description>&lt;P&gt;To_date() is an oracle function yes?&amp;nbsp; Maybe:&lt;/P&gt;
&lt;PRE&gt;to_date("&amp;amp;testvar.")&lt;/PRE&gt;
&lt;P&gt;You may need to specify a format also.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or do you mean this function:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=ds2ref&amp;amp;docsetTarget=n0l7ar188h314dn1dlgztkiknays.htm&amp;amp;docsetVersion=3.1&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?docsetId=ds2ref&amp;amp;docsetTarget=n0l7ar188h314dn1dlgztkiknays.htm&amp;amp;docsetVersion=3.1&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Because that is expecting a number of days, so you would need to input() the text from that macro variable.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 14:11:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/insert-date-variable-into-table-from-a-marcro/m-p/507157#M32341</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-10-24T14:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: insert date variable into table from a marcro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/insert-date-variable-into-table-from-a-marcro/m-p/507159#M32343</link>
      <description>&lt;P&gt;Is your rundate values are in datetime format, then you might need to change your create table&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data testtable;
format rundate datetime26.;
rundate='17OCT2018:14:45:32'DT;output;
rundate='18OCT2018:14:45:32'DT;output;
run;

proc sql;
select max(rundate) into: testvar SEPARATED BY '' from testtable;
create table rundatelist (
tablename varchar(100),
rundate num format=datetime26.);

insert into rundatelist (tablename, rundate) values ('table1', &amp;amp;testvar);  /*this line does not work*/
select * from rundatelist;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to insert only date instead of datetime then use datepart() to extract date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select datepart(max(rundate)) into: testvar SEPARATED BY '' from testtable;
create table rundatelist (
tablename varchar(100),
rundate date);

insert into rundatelist (tablename, rundate) values ('table1', &amp;amp;testvar);  /*this line does not work*/
select * from rundatelist;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 14:21:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/insert-date-variable-into-table-from-a-marcro/m-p/507159#M32343</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-10-24T14:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: insert date variable into table from a marcro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/insert-date-variable-into-table-from-a-marcro/m-p/507177#M32344</link>
      <description>&lt;P&gt;Suryakrian,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your answer.&amp;nbsp; I included dt after to&amp;nbsp;use the logic with a macro.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 14:48:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/insert-date-variable-into-table-from-a-marcro/m-p/507177#M32344</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-10-24T14:48:06Z</dc:date>
    </item>
  </channel>
</rss>

