<?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: Character Value in Macro variable in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237908#M55384</link>
    <description>&lt;P&gt;The complete code is too long but is repition of the codes that I have shared. If you check the log, macro variable Plan_type gets resolved to the correct value which is 'PREM', its only when it appears in the where statement, SAS somehow is considering it as column name instead of a value in the column.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Dec 2015 22:14:45 GMT</pubDate>
    <dc:creator>Anuashla</dc:creator>
    <dc:date>2015-12-04T22:14:45Z</dc:date>
    <item>
      <title>Character Value in Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237898#M55378</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With the code below, I am trying to filter the rows in a table where&amp;nbsp;&lt;SPAN&gt;ESP01.SCAT_SALES_CATG2_C has 'PREM' (macro variable &lt;EM&gt;Plan_type&amp;nbsp;&lt;/EM&gt;is resolving correctly to 'PREM')&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;values. But instead, program is considering 'PREM' as the name of a column and giving me an error as pasted below. The way I want the statement to resolve is&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ESP01.SCAT_SALES_CATG2_C EQ 'PREM'.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please suggest where I am making a mistake.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;%macro datacall;&lt;BR /&gt;%do i=1 %to 160;&lt;BR /&gt;proc sql;&lt;BR /&gt;select start_year into: year from splits_grid1 where ID=&amp;amp;i;&lt;BR /&gt;select plan_type into: plan_type from splits_grid1 where ID=&amp;amp;i;&lt;BR /&gt;select contract_type into: contract_type from splits_grid1 where ID=&amp;amp;i;&lt;BR /&gt;quit;&lt;BR /&gt;%data (CNTRCT_START_Y, ESP01.SCAT_SALES_CATG2_C EQ "&amp;amp;PLAN_TYPE" and EXTRACT(YEAR FROM ESP01.CNTRCT_START_Y)=&amp;amp;YEAR AND&lt;BR /&gt;ESP01.PLTYP_CNTCT_TYPE_C EQ "&amp;amp;CONTRACT_TYPE" and ESP01.COUNTRY_ISO3_C EQ 'CAN', &amp;amp;YEAR&amp;amp;PLAN_TYPE&amp;amp;CONTRACT_TYPE);&lt;BR /&gt;%end;&lt;BR /&gt;%mend datacall;&lt;BR /&gt;%datacall;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOG Details:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;MLOGIC(DATA): Beginning execution.&lt;BR /&gt;SYMBOLGEN: Macro variable PLAN_TYPE resolves to PREM&lt;BR /&gt;SYMBOLGEN: Macro variable YEAR resolves to 2000&lt;BR /&gt;SYMBOLGEN: Macro variable CONTRACT_TYPE resolves to N&lt;BR /&gt;SYMBOLGEN: Macro variable YEAR resolves to 2000&lt;BR /&gt;SYMBOLGEN: Macro variable PLAN_TYPE resolves to PREM&lt;BR /&gt;SYMBOLGEN: Macro variable CONTRACT_TYPE resolves to N&lt;BR /&gt;MLOGIC(DATA): Parameter START_DATE has value CNTRCT_START_Y&lt;BR /&gt;MLOGIC(DATA): Parameter WHERE has value ESP01.SCAT_SALES_CATG2_C EQ "PREM" and EXTRACT(YEAR FROM ESP01.CNTRCT_START_Y)= 2000&lt;BR /&gt;AND ESP01.PLTYP_CNTCT_TYPE_C EQ "N" and ESP01.COUNTRY_ISO3_C EQ 'CAN'&lt;BR /&gt;MLOGIC(DATA): Parameter OUTDATA has value 2000PREMN&lt;BR /&gt;SYMBOLGEN: Macro variable START_DATE resolves to CNTRCT_START_Y&lt;BR /&gt;SYMBOLGEN: Macro variable WHERE resolves to ESP01.SCAT_SALES_CATG2_C EQ "PREM" and EXTRACT(YEAR FROM ESP01.CNTRCT_START_Y)=&lt;BR /&gt;2000 AND ESP01.PLTYP_CNTCT_TYPE_C EQ "N" and ESP01.COUNTRY_ISO3_C EQ 'CAN'&lt;/P&gt;&lt;P&gt;ERROR: CLI prepare error: [Teradata][ODBC Teradata Driver][Teradata Database] Column PREM not found in ESPARS_View.ESP01.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2015 21:23:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237898#M55378</guid>
      <dc:creator>Anuashla</dc:creator>
      <dc:date>2015-12-04T21:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: Character Value in Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237901#M55379</link>
      <description>&lt;P&gt;Can you post the code from the %data() macro? I think the error is in there somewhere instead of what you've posted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would expect an error of the form mostly likely seeing &amp;amp;PLANTYPE macro without the quotes.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Though&amp;nbsp;@ballardw may have hit the nail on the head with the macro variable, if any of them had trailing spaces that wouldn't resolve properly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2015 21:52:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237901#M55379</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-12-04T21:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: Character Value in Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237902#M55380</link>
      <description>&lt;P&gt;I'm going to suggest that MPRINT would be more helpful than symbolgen and mlogic here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't give any details of the macro data so how you are using your variable is pretty much a mystery.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We don't know which positional variable receives the value &amp;nbsp;&amp;amp;YEAR&amp;amp;PLAN_TYPE&amp;amp;CONTRACT_TYPE .&lt;/P&gt;
&lt;P&gt;I would check what that string resolves to as I suspect you may have wanted something like &amp;nbsp;&amp;amp;YEAR&lt;STRONG&gt;.&lt;/STRONG&gt;&amp;amp;PLAN_TYPE&lt;STRONG&gt;.&lt;/STRONG&gt;&amp;amp;CONTRACT_TYPE where the . are the macro separator for combining values.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2015 21:41:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237902#M55380</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-12-04T21:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: Character Value in Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237904#M55381</link>
      <description>&lt;P&gt;Hello Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code for the macro Data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro data (start_date, where, outdata);&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CONNECT TO ODBC (USER=xxxxxxxxx PW=xxxxxxxxx DSN=xxxxxxx);&lt;BR /&gt;CREATE TABLE DATA1 AS&lt;BR /&gt;SELECT * FROM CONNECTION TO ODBC&lt;BR /&gt;(&lt;BR /&gt;SELECT DISTINCT&lt;BR /&gt;(ESP01.CNTRCT_CONTRACT_R||ESP01.VEH_VIN_C) AS CONTRACT_VIN,&lt;BR /&gt;EXTRACT(YEAR FROM ESP01.CNTRCT_START_Y) AS START_YEAR,&lt;BR /&gt;CAST ( (ESP01.&amp;amp;START_DATE (FORMAT 'YYYYMM') ) as CHAR(6) ) as START_DATE, /*Contract start time for new vehicle*/&lt;BR /&gt;ESP01.PLAN_CNT_CVG_TME_R as term&lt;BR /&gt;FROM&lt;BR /&gt;ESPARS_View.SSEPR01 as ESP01&lt;BR /&gt;WHERE&lt;BR /&gt;ESP01.CNTRCT_TEST_MKT_F = 'N' /* necessary constraint to get rid of the free contracts*/&lt;BR /&gt;AND &amp;amp;where /*Macro variable for all conditions to filter the contracts*/&lt;BR /&gt;AND ESP01.PLBRN_PRDCT_LINE_C IN ('C', 'E', 'F')/* necessary constraint to pull the right contracts*/&lt;BR /&gt;order by 1,2&lt;/P&gt;&lt;P&gt;);&lt;BR /&gt;DISCONNECT FROM ODBC;&lt;BR /&gt;QUIT;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2015 22:12:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237904#M55381</guid>
      <dc:creator>Anuashla</dc:creator>
      <dc:date>2015-12-04T22:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Character Value in Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237905#M55382</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not bothered as much about how&amp;nbsp;&lt;SPAN&gt;&amp;amp;YEAR&amp;amp;PLAN_TYPE&amp;amp;CONTRACT_TYPE resolves. This is just a dataset name and I can chang eit anytime. I am more concerned about how the where clause variables are getting resolved in the macro. I have pasted the code for macro. I believe it should provide information as to which positional variable is taking whihc value.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;P.S.&amp;nbsp;&lt;SPAN&gt;&amp;amp;YEAR&amp;amp;PLAN_TYPE&amp;amp;CONTRACT_TYPE is resolving correctly and giving me result as I expected. Thank you for helping though. I would try turning MPRINT option on and see if it helps me resolve the issue.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2015 22:00:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237905#M55382</guid>
      <dc:creator>Anuashla</dc:creator>
      <dc:date>2015-12-04T22:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: Character Value in Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237906#M55383</link>
      <description>You don't actually use the OUTDATA macro variable anywhere in your posted code....so the resolution of the macro variable there doesn't matter. Is that the full code?</description>
      <pubDate>Fri, 04 Dec 2015 22:07:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237906#M55383</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-12-04T22:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: Character Value in Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237908#M55384</link>
      <description>&lt;P&gt;The complete code is too long but is repition of the codes that I have shared. If you check the log, macro variable Plan_type gets resolved to the correct value which is 'PREM', its only when it appears in the where statement, SAS somehow is considering it as column name instead of a value in the column.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2015 22:14:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237908#M55384</guid>
      <dc:creator>Anuashla</dc:creator>
      <dc:date>2015-12-04T22:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: Character Value in Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237909#M55385</link>
      <description>&lt;P&gt;This is the [art where I am using Outdata macro variable. It is to create different datasets which I will need to append in the end. I guess this has nothign to do with my issue here???&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DATA DATA_&amp;amp;OUTDATA;&lt;BR /&gt;MERGE CONTRACTS_DETAILS (IN=A)&lt;BR /&gt;CLAIMS1 (IN=B);&lt;BR /&gt;BY CONTRACT_VIN EXPOSURE;&lt;BR /&gt;IF A AND NOT B THEN CLAIM=0;&lt;BR /&gt;IF A AND B THEN CLAIM=1;&lt;BR /&gt;IF A;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2015 22:16:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237909#M55385</guid>
      <dc:creator>Anuashla</dc:creator>
      <dc:date>2015-12-04T22:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Character Value in Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237910#M55386</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/64435"&gt;@Anuashla﻿&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Given the messages in the log I believe the issue is caused by the&amp;nbsp;double quotes around PREM. You need to use single quotes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;SYMBOLGEN: Macro variable WHERE resolves to &lt;STRONG&gt;ESP01.SCAT_SALES_CATG2_C EQ &lt;FONT color="#FF0000"&gt;"&lt;/FONT&gt;PREM&lt;FONT color="#FF0000"&gt;"&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;ERROR: CLI prepare error: [Teradata][ODBC Teradata Driver][Teradata Database] &lt;STRONG&gt;Column PREM not found&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In Teradata SQL double quotes are used for quoting names (eg. a column name) not strings. If&amp;nbsp;using double quotes Teradata expects&amp;nbsp;"PREM" to be an existing column name. That's why you get the error " Column PREM not found".&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.info.teradata.com/HTMLPubs/DB_TTU_14_00/index.html#page/SQL_Reference/B035_1141_111A/ch01.103.19.html" target="_blank"&gt;http://www.info.teradata.com/HTMLPubs/DB_TTU_14_00/index.html#page/SQL_Reference/B035_1141_111A/ch01.103.19.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2015 22:40:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237910#M55386</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-12-04T22:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: Character Value in Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237911#M55387</link>
      <description>&lt;P&gt;Hello Patrick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried using single quote. Still no success. Here is the log for that&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MLOGIC(DATA): Beginning execution.&lt;BR /&gt;SYMBOLGEN: Macro variable YEAR resolves to 2000&lt;BR /&gt;SYMBOLGEN: Macro variable YEAR resolves to 2000&lt;BR /&gt;SYMBOLGEN: Macro variable PLAN_TYPE resolves to PREM&lt;BR /&gt;SYMBOLGEN: Macro variable CONTRACT_TYPE resolves to N&lt;BR /&gt;MLOGIC(DATA): Parameter START_DATE has value CNTRCT_START_Y&lt;BR /&gt;MLOGIC(DATA): Parameter WHERE has value ESP01.SCAT_SALES_CATG2_C EQ '&amp;amp;PLAN_TYPE' and EXTRACT(YEAR FROM ESP01.CNTRCT_START_Y)=&lt;BR /&gt;2000 AND ESP01.PLTYP_CNTCT_TYPE_C EQ '&amp;amp;CONTRACT_TYPE' and ESP01.COUNTRY_ISO3_C EQ 'CAN'&lt;BR /&gt;MLOGIC(DATA): Parameter OUTDATA has value 2000PREMN&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2015 22:40:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237911#M55387</guid>
      <dc:creator>Anuashla</dc:creator>
      <dc:date>2015-12-04T22:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: Character Value in Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237912#M55388</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/64435"&gt;@Anuashla﻿&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;It's not working because you need to code in a way that macro variable &amp;amp;contract_type resolves before you wrap it into single quotes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post the code snippet where you construct/populate macro variable &amp;amp;where&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to populate &amp;amp;where following an approach as below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let string=Alfred;
%let where= name = %unquote(%nrbquote(')&amp;amp;string%nrbquote('));

proc sql;
  select *
  from sashelp.class
  where &amp;amp;where
  ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2015 22:51:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237912#M55388</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-12-04T22:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: Character Value in Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237916#M55389</link>
      <description>&lt;P&gt;Since you&amp;nbsp;are using an "&lt;STRONG&gt;explicit&lt;/STRONG&gt;" rather than "&lt;STRONG&gt;implicit&lt;/STRONG&gt;" pass-through SQL statement, your double quotes are being&amp;nbsp;interpreted&amp;nbsp;as a quoted identifiers. In&amp;nbsp;ANSI-compliant SQL databases,&amp;nbsp;double quotes are reserved for object/column&amp;nbsp;names&amp;nbsp;that contain non-standard characters. An example of an ANSI-compliant column&amp;nbsp;name would be &lt;STRONG&gt;CUSTOMER_ID_NUM &lt;/STRONG&gt;(quotes are optional); an example of a non-compliant column name would be "&lt;STRONG&gt;customer-id-#&lt;/STRONG&gt;" (in which case, quotes are mandatory).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in your PROC SQL statement ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &lt;U&gt;change:&lt;/U&gt;&amp;nbsp; &amp;amp;where&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &lt;U&gt;to:&lt;/U&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %SYSFUNC(TRANSLATE(&amp;amp;where, %BQUOTE("'), %BQUOTE('")))&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively, you should avoid using double quotes altogether,&amp;nbsp;for anything that follows the "connection to ODBC ... " statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro data (start_date, where, outdata);

  PROC SQL;
    CONNECT TO ODBC (USER=xxxxxxxxx PW=xxxxxxxxx DSN=xxxxxxx);
    CREATE TABLE DATA1 AS
    SELECT * FROM CONNECTION TO ODBC (
      SELECT DISTINCT
        (ESP01.CNTRCT_CONTRACT_R||ESP01.VEH_VIN_C) AS CONTRACT_VIN,
        EXTRACT(YEAR FROM ESP01.CNTRCT_START_Y) AS START_YEAR,
        CAST ( (ESP01.&amp;amp;START_DATE (FORMAT 'YYYYMM') ) as CHAR(6) ) as START_DATE, /*Contract start time for new vehicle*/
        ESP01.PLAN_CNT_CVG_TME_R as term
      FROM
        ESPARS_View.SSEPR01 as ESP01
      WHERE
        ESP01.CNTRCT_TEST_MKT_F = 'N' /* necessary constraint to get rid of the free contracts*/
        AND %SYSFUNC(TRANSLATE(&amp;amp;where, %BQUOTE("'), %BQUOTE('"))) /*Macro variable for all conditions to filter the contracts*/
        AND ESP01.PLBRN_PRDCT_LINE_C IN ('C', 'E', 'F')/* necessary constraint to pull the right contracts*/
      order by 1,2
    );
    DISCONNECT FROM ODBC;
  QUIT;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2015 23:27:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/237916#M55389</guid>
      <dc:creator>hbi</dc:creator>
      <dc:date>2015-12-04T23:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: Character Value in Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/238074#M55398</link>
      <description>&lt;P&gt;I tried following the method you suggested using BQUOTE and Sysfunc but it still gives me the same error saying column PREM not found.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2015 15:01:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/238074#M55398</guid>
      <dc:creator>Anuashla</dc:creator>
      <dc:date>2015-12-07T15:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: Character Value in Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/238147#M55409</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/64435"&gt;@Anuashla﻿&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Please look at the code I've previously posted. It's a working sample which you can run in your own environment if you wish to. If things don't work for you then you must be doing something differently.&lt;/P&gt;
&lt;P&gt;Please post your code - and/or post the log where you run your code with option MPRINT turned on; and then post the parts where we see to what the macro resolves to as well as the part where SAS throws an error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2015 19:37:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-Value-in-Macro-variable/m-p/238147#M55409</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-12-07T19:37:37Z</dc:date>
    </item>
  </channel>
</rss>

