<?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: Unable to get data with prompts in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Unable-to-get-data-with-prompts/m-p/446609#M28891</link>
    <description>&lt;P&gt;thanks! I was able to get what I need with %bquote&lt;/P&gt;</description>
    <pubDate>Sun, 18 Mar 2018 20:00:10 GMT</pubDate>
    <dc:creator>mrdlau</dc:creator>
    <dc:date>2018-03-18T20:00:10Z</dc:date>
    <item>
      <title>Unable to get data with prompts</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Unable-to-get-data-with-prompts/m-p/446490#M28885</link>
      <description>&lt;P&gt;I have a query that I'm trying to put in prompts, but it seems to not give me data or errors&amp;nbsp;when the prompts are used&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The original code is something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select 
*
FROM table 1
WHERE State = 'TX'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This gives me the expected result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However,&amp;nbsp; in SAS EG,&amp;nbsp; when I do this, it gives me 0 results&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select 
*
FROM table 1
WHERE State = '&amp;amp;State'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have created the 'State' prompt as text and tied it to the task.&amp;nbsp; The code runs fine and gives me the pop-up box, but does gives me 0 rows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I already tried single quotes and double quotes, but not change.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once this is fixed, I'm also trying to figure out how to put dates in.&lt;/P&gt;
&lt;P&gt;Here is original vs what I want.&lt;/P&gt;
&lt;P&gt;Original:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select 
*
FROM table 1
WHERE State = 'TX'
AND date1 between '2018-03-01' AND '2018-03-15'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What I want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select 
*
FROM table 1
WHERE State = &amp;amp;State
AND date1 between '&amp;amp;begin' AND '&amp;amp;End'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'm also running the date as text but I get the following error&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Error: Teradata prepare: A character string failed conversion to a numeric value: SQL Statement was: SELECT&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Mar 2018 22:14:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Unable-to-get-data-with-prompts/m-p/446490#M28885</guid>
      <dc:creator>mrdlau</dc:creator>
      <dc:date>2018-03-17T22:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to get data with prompts</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Unable-to-get-data-with-prompts/m-p/446506#M28886</link>
      <description>&lt;P&gt;Macro variables only resolve in double quotes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WHERE State = "&amp;amp;State"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/38339"&gt;@mrdlau&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have a query that I'm trying to put in prompts, but it seems to not give me data or errors&amp;nbsp;when the prompts are used&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The original code is something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select 
*
FROM table 1
WHERE State = 'TX'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This gives me the expected result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However,&amp;nbsp; in SAS EG,&amp;nbsp; when I do this, it gives me 0 results&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select 
*
FROM table 1
WHERE State = '&amp;amp;State'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have created the 'State' prompt as text and tied it to the task.&amp;nbsp; The code runs fine and gives me the pop-up box, but does gives me 0 rows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I already tried single quotes and double quotes, but not change.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once this is fixed, I'm also trying to figure out how to put dates in.&lt;/P&gt;
&lt;P&gt;Here is original vs what I want.&lt;/P&gt;
&lt;P&gt;Original:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select 
*
FROM table 1
WHERE State = 'TX'
AND date1 between '2018-03-01' AND '2018-03-15'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What I want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select 
*
FROM table 1
WHERE State = &amp;amp;State
AND date1 between '&amp;amp;begin' AND '&amp;amp;End'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'm also running the date as text but I get the following error&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Error: Teradata prepare: A character string failed conversion to a numeric value: SQL Statement was: SELECT&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Mar 2018 22:59:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Unable-to-get-data-with-prompts/m-p/446506#M28886</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-17T22:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to get data with prompts</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Unable-to-get-data-with-prompts/m-p/446594#M28889</link>
      <description>&lt;P&gt;In SAS, dates are typically rendered as "18mar2018"d, with the d after the quotes signifying that it's a date, not a character variable. It looks like your dates are character variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is something where you may need to experiment a bit to ensure that SAS is giving Teradata a date that matches what it's expecting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Sun, 18 Mar 2018 16:42:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Unable-to-get-data-with-prompts/m-p/446594#M28889</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2018-03-18T16:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to get data with prompts</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Unable-to-get-data-with-prompts/m-p/446597#M28890</link>
      <description>&lt;P&gt;SAS does not care whether you use single or double quotes around literal values.&amp;nbsp; But Teradata does.&amp;nbsp; It only uses single quotes for literal values. When it sees double quotes then it expects the name of an object (variable name, table name , etc).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the SAS macro process cares about the type of quote character used. Macro variable values are not resolved inside of single quotes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you need to work a little harder to get single quotes around the value of a macro variable.&amp;nbsp; The easiest way is to use a data step.&amp;nbsp; So if you have two macro variables named START and STOP you could run the data step to add single quotes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  call symputx('start',quote(symget('start',"'"));
  call symputx('stop',quote(symget('stop',"'"));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So your program might look like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  call symputx('start',quote(symget('start',"'"));
  call symputx('stop',quote(symget('stop',"'"));
run;
proc sql noprint ;
connect to teradata (......);
create table want as select * from connection to teradata
(select * from mytable where date between &amp;amp;start and &amp;amp;stop)
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to use pure macro code (which you don't since you are already generating SAS code) then something like this can work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start=%bquote('&amp;amp;start');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But then you send up with macro quoting around the string.&amp;nbsp; It probably wouldn't matter if you are pushing it into a pass through SQL query.&amp;nbsp; But you can remove the macro quoting with the %unquote() macro function.&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>Sun, 18 Mar 2018 17:12:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Unable-to-get-data-with-prompts/m-p/446597#M28890</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-18T17:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to get data with prompts</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Unable-to-get-data-with-prompts/m-p/446609#M28891</link>
      <description>&lt;P&gt;thanks! I was able to get what I need with %bquote&lt;/P&gt;</description>
      <pubDate>Sun, 18 Mar 2018 20:00:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Unable-to-get-data-with-prompts/m-p/446609#M28891</guid>
      <dc:creator>mrdlau</dc:creator>
      <dc:date>2018-03-18T20:00:10Z</dc:date>
    </item>
  </channel>
</rss>

