<?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 Error in proc SQL with Macro Variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-in-proc-SQL-with-Macro-Variable/m-p/81778#M17656</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looking for a solution to an isue when I use Macro variables in a proc sql statement.&amp;nbsp; Here's what I'm doing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The dataset(dailyRun) I'm working with has a field called ScID. This is character field with a length of 10&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code;&lt;/P&gt;&lt;P&gt;Prompt manager has a prompt called mySCID that will be filled in by the user when they run the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;code to create a table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table test as&lt;/P&gt;&lt;P&gt;select ScID from dailyRun&lt;/P&gt;&lt;P&gt;where ScID=&amp;amp;mySCID;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get the following error "expression using equals(=)&amp;nbsp; has components that are different data types"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The &amp;amp;mySCID variable has 00100200 as the value.&amp;nbsp; If&amp;nbsp; I change the code and place the value '00100200' it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table test as&lt;/P&gt;&lt;P&gt;select ScID from dailyRun&lt;/P&gt;&lt;P&gt;where ScID=&lt;STRONG&gt;'00100200'&lt;/STRONG&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 12 Apr 2012 18:41:11 GMT</pubDate>
    <dc:creator>bman</dc:creator>
    <dc:date>2012-04-12T18:41:11Z</dc:date>
    <item>
      <title>Error in proc SQL with Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-proc-SQL-with-Macro-Variable/m-p/81778#M17656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looking for a solution to an isue when I use Macro variables in a proc sql statement.&amp;nbsp; Here's what I'm doing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The dataset(dailyRun) I'm working with has a field called ScID. This is character field with a length of 10&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code;&lt;/P&gt;&lt;P&gt;Prompt manager has a prompt called mySCID that will be filled in by the user when they run the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;code to create a table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table test as&lt;/P&gt;&lt;P&gt;select ScID from dailyRun&lt;/P&gt;&lt;P&gt;where ScID=&amp;amp;mySCID;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get the following error "expression using equals(=)&amp;nbsp; has components that are different data types"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The &amp;amp;mySCID variable has 00100200 as the value.&amp;nbsp; If&amp;nbsp; I change the code and place the value '00100200' it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table test as&lt;/P&gt;&lt;P&gt;select ScID from dailyRun&lt;/P&gt;&lt;P&gt;where ScID=&lt;STRONG&gt;'00100200'&lt;/STRONG&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2012 18:41:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-proc-SQL-with-Macro-Variable/m-p/81778#M17656</guid>
      <dc:creator>bman</dc:creator>
      <dc:date>2012-04-12T18:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: Error in proc SQL with Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-proc-SQL-with-Macro-Variable/m-p/81779#M17657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;try this:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table test as&lt;/P&gt;&lt;P&gt;select ScID from dailyRun&lt;/P&gt;&lt;P&gt;where ScID="&amp;amp;mySCID";&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Linlin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2012 19:00:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-proc-SQL-with-Macro-Variable/m-p/81779#M17657</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-04-12T19:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: Error in proc SQL with Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-proc-SQL-with-Macro-Variable/m-p/81780#M17658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks that worked.&amp;nbsp; What does the double quotes do when SAS reads it. Does it convert the macro variable?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2012 19:10:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-proc-SQL-with-Macro-Variable/m-p/81780#M17658</guid>
      <dc:creator>bman</dc:creator>
      <dc:date>2012-04-12T19:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: Error in proc SQL with Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-proc-SQL-with-Macro-Variable/m-p/81781#M17659</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 12pt; background: white; font-family: 'Courier New';"&gt;When comparing character variable with a value, we have to add “ “ to the value.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 12pt; background: white; font-family: 'Courier New';"&gt;It is the same as “&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 12pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 12pt;"&gt; sex=&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: purple; font-size: 12pt;"&gt;"F"&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 12pt;"&gt;;” in the code below:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 12pt; background: white; font-family: 'Courier New';"&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 12pt; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 12pt;"&gt; want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 12pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 12pt;"&gt; sashelp.class;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue; font-size: 12pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 12pt;"&gt; sex=&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: purple; font-size: 12pt;"&gt;"F" ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;STRONG style="color: navy; font-size: 12pt; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black; font-size: 12pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2012 19:24:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-proc-SQL-with-Macro-Variable/m-p/81781#M17659</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-04-12T19:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: Error in proc SQL with Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-proc-SQL-with-Macro-Variable/m-p/81782#M17660</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. How would it work for a date prompt. I know when I have to do&amp;nbsp; a date value i place '01Apr2011',d when the field I'm checking against is a date field.&amp;nbsp; If I use a prompt for that and the user places 01apr2011 or 04012011 would I just put that variable in "" too?&amp;nbsp; I really appreciate your help. I'm new to SAS coding.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2012 20:27:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-proc-SQL-with-Macro-Variable/m-p/81782#M17660</guid>
      <dc:creator>bman</dc:creator>
      <dc:date>2012-04-12T20:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Error in proc SQL with Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-proc-SQL-with-Macro-Variable/m-p/81783#M17661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;yes, you have to put the macro variable in " ".&amp;nbsp; example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let dt=01apr2011;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;format date mmddyy10.;&lt;/P&gt;&lt;P&gt;input date mmddyy8.;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;03012011&lt;/P&gt;&lt;P&gt;04012011&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;if date="&amp;amp;dt"d;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Linlin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2012 22:09:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-proc-SQL-with-Macro-Variable/m-p/81783#M17661</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-04-12T22:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: Error in proc SQL with Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-in-proc-SQL-with-Macro-Variable/m-p/81784#M17662</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you. I really appreciate the help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2012 22:34:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-in-proc-SQL-with-Macro-Variable/m-p/81784#M17662</guid>
      <dc:creator>bman</dc:creator>
      <dc:date>2012-04-12T22:34:18Z</dc:date>
    </item>
  </channel>
</rss>

