<?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: Invalid argument to function QUOTE in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Invalid-argument-to-function-QUOTE/m-p/71935#M15549</link>
    <description>Do you have an observation where the JOB_CLASS variable is blank?  Also, you may want to consider adding DISTINCT to the SELECT in PROC SQL, so that you only get one of each JOB_CLASS value generated in your macro variable.  And, there is a max length limit for a SAS macro variable - just in case you might exceed that with your PROC SQL, by the way.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
    <pubDate>Wed, 16 Sep 2009 18:52:07 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2009-09-16T18:52:07Z</dc:date>
    <item>
      <title>Invalid argument to function QUOTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-argument-to-function-QUOTE/m-p/71934#M15548</link>
      <description>I'm currently getting this error:&lt;BR /&gt;
NOTE: Invalid argument to function QUOTE. Missing values may be generated.&lt;BR /&gt;
NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;
NOTE: Line generated by the macro variable "EXLCL".&lt;BR /&gt;
64         ,,&lt;BR /&gt;
           _&lt;BR /&gt;
           22&lt;BR /&gt;
           76&lt;BR /&gt;
ERROR: Syntax error while parsing WHERE clause.&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, -.  &lt;BR /&gt;
ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;
&lt;BR /&gt;
when I run this code:&lt;BR /&gt;
proc summary data=test NWAY completetypes;&lt;BR /&gt;
   class job_class inj_yr;&lt;BR /&gt;
   var avg_emp; &lt;BR /&gt;
   output out=out1 (where=(inj_yr='2008' and avg_emp in(.,0))) sum= ;&lt;BR /&gt;
run; &lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
   select quote(job_class)&lt;BR /&gt;
   into: exlcl separated by ','&lt;BR /&gt;
   from out1; &lt;BR /&gt;
quit; &lt;BR /&gt;
%put &amp;amp;exlcl;&lt;BR /&gt;
&lt;BR /&gt;
proc report data=test nowd &lt;BR /&gt;
	style(header)=[font_weight=bold];&lt;BR /&gt;
	options missing='0';&lt;BR /&gt;
	where job_class not in (&amp;amp;exlcl); &lt;BR /&gt;
	columns job_class year, (avg_emp);&lt;BR /&gt;
&lt;BR /&gt;
The variable job_class is a categorical variable. Some of its categories are: Plant Equipment, Engineer, and Clerical Worker.&lt;BR /&gt;
&lt;BR /&gt;
The file out1 appears to be generated correctly.&lt;BR /&gt;
Any ideas?&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Jason</description>
      <pubDate>Wed, 16 Sep 2009 18:40:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-argument-to-function-QUOTE/m-p/71934#M15548</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-09-16T18:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid argument to function QUOTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-argument-to-function-QUOTE/m-p/71935#M15549</link>
      <description>Do you have an observation where the JOB_CLASS variable is blank?  Also, you may want to consider adding DISTINCT to the SELECT in PROC SQL, so that you only get one of each JOB_CLASS value generated in your macro variable.  And, there is a max length limit for a SAS macro variable - just in case you might exceed that with your PROC SQL, by the way.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 16 Sep 2009 18:52:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-argument-to-function-QUOTE/m-p/71935#M15549</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-09-16T18:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid argument to function QUOTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-argument-to-function-QUOTE/m-p/71936#M15550</link>
      <description>None of the observations in job_class are blank.&lt;BR /&gt;
I tried adding DISTINCT and I received the same error:&lt;BR /&gt;
NOTE: Invalid argument to function QUOTE. Missing values may be generated.&lt;BR /&gt;
where job_class not in (&amp;amp;exlcl);&lt;BR /&gt;
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant, a datetime constant, a missing value.  &lt;BR /&gt;
&lt;BR /&gt;
I also did some testing and found that I still get the same error when I use jobs with 1 word titles (eg Engineer).</description>
      <pubDate>Wed, 16 Sep 2009 20:19:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-argument-to-function-QUOTE/m-p/71936#M15550</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-09-16T20:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid argument to function QUOTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-argument-to-function-QUOTE/m-p/71937#M15551</link>
      <description>Very strange.&lt;BR /&gt;
&lt;BR /&gt;
You may expect this kind of error message when you are trying to hold a quoted expression in a variable which is too small in length. Say you have variable B="AAA" with a $3 length, B=quote('AAA') would produce that error, because B cannot hold ' "AAA" '&lt;BR /&gt;
The SQL expression is completely different and should dynamically store the result of the quote function. But, anyway try this mod to see if it works.&lt;BR /&gt;
&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
select quote(job_class) length=50&lt;BR /&gt;
into: exlcl separated by ','&lt;BR /&gt;
from out1;&lt;BR /&gt;
quit; &lt;BR /&gt;
&lt;BR /&gt;
Adjust the length to a large enough size for the the job_class variable.&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;</description>
      <pubDate>Thu, 17 Sep 2009 11:30:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-argument-to-function-QUOTE/m-p/71937#M15551</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2009-09-17T11:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid argument to function QUOTE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-argument-to-function-QUOTE/m-p/71938#M15552</link>
      <description>The DISTINCT suggestion is unrelated to your error - it was a suggestion to avoid extraneous duplicates being generated in your macro variable.  I suggest diagnosing the problem by removing the QUOTE function just to see what gets generated as shown in the %PUT statement that follows.  Then maybe you can determine what SAS is complaining about, based on your data.  These are suggestions for you to help diagnose the warning/error.&lt;BR /&gt;
&lt;BR /&gt;
Here's another coding technique to consider - maybe you will not get the error/warning:&lt;BR /&gt;
&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
select '"' !! trim(job_class) !! '"'&lt;BR /&gt;
into: exlcl separated by ','&lt;BR /&gt;
from out1; &lt;BR /&gt;
quit; &lt;BR /&gt;
%put &amp;amp;exlcl;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 17 Sep 2009 12:40:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-argument-to-function-QUOTE/m-p/71938#M15552</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-09-17T12:40:59Z</dc:date>
    </item>
  </channel>
</rss>

