<?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: How to use a sas variable in select statement in proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-sas-variable-in-select-statement-in-proc-sql/m-p/653334#M196243</link>
    <description>Thanks. It works</description>
    <pubDate>Thu, 04 Jun 2020 16:40:06 GMT</pubDate>
    <dc:creator>adisal</dc:creator>
    <dc:date>2020-06-04T16:40:06Z</dc:date>
    <item>
      <title>How to use a sas variable in select statement in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-sas-variable-in-select-statement-in-proc-sql/m-p/653279#M196233</link>
      <description>&lt;P&gt;I want to use the month and year from today's date and use that as a column in SQL table .&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the code that I am using to get the month and year :&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;CUR_MONTH =today();&lt;BR /&gt;format CUR_MONTH yymmn6.;&lt;BR /&gt;put CUR_MONTH;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now , I want to use the variable&amp;nbsp;CUR_MONTH in SELECT statement , something like :&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;SELECT&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;amp;CUR_MONTH , ID , NAME FROM ABC;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But , I get Error ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,&lt;BR /&gt;a missing value, (, *, +, -, ALL, BTRIM, CALCULATED, CASE, DISTINCT, EXISTS, INPUT, NOT, PUT, SUBSTRING, TRANSLATE,&lt;BR /&gt;UNIQUE, USER, ^, ~.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone please guide . Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 16:01:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-sas-variable-in-select-statement-in-proc-sql/m-p/653279#M196233</guid>
      <dc:creator>adisal</dc:creator>
      <dc:date>2020-06-04T16:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a sas variable in select statement in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-sas-variable-in-select-statement-in-proc-sql/m-p/653283#M196237</link>
      <description>&lt;P&gt;Try:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
&amp;nbsp; &amp;nbsp; call symputx('CUR_MONTH', put(today(), yymmn6.));
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This will initialize CUR_MONTH as a macro variable, which you can use in the subsequent PROC SQL statement.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 16:18:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-sas-variable-in-select-statement-in-proc-sql/m-p/653283#M196237</guid>
      <dc:creator>mklangley</dc:creator>
      <dc:date>2020-06-04T16:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a sas variable in select statement in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-sas-variable-in-select-statement-in-proc-sql/m-p/653334#M196243</link>
      <description>Thanks. It works</description>
      <pubDate>Thu, 04 Jun 2020 16:40:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-sas-variable-in-select-statement-in-proc-sql/m-p/653334#M196243</guid>
      <dc:creator>adisal</dc:creator>
      <dc:date>2020-06-04T16:40:06Z</dc:date>
    </item>
  </channel>
</rss>

