<?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: Error:Expecting a name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-Expecting-a-name/m-p/648066#M194046</link>
    <description>i hv already posted complete code and log too</description>
    <pubDate>Fri, 15 May 2020 15:21:57 GMT</pubDate>
    <dc:creator>rohithverma</dc:creator>
    <dc:date>2020-05-15T15:21:57Z</dc:date>
    <item>
      <title>Error:Expecting a name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Expecting-a-name/m-p/648036#M194025</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While executing the below query i have got an error as shared in the snapshot. Please let me know where the query had went wrong&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;QUERY:&lt;/P&gt;
&lt;P&gt;PROC SQL;&lt;BR /&gt;SELECT COUNT(DISTINCT(AUTHORIZEDBY)) INTO: CNT FROM INTIAL;&lt;BR /&gt;SELECT DISTINCT(AUTHORIZEDBY) INTO : AUT1-: %SYSFUNC(COMPRESS(AUT&amp;amp;CNT)) FROM INTIAL;&lt;BR /&gt;QUIT;&lt;BR /&gt;%PUT &amp;amp;AUT1;&lt;BR /&gt;options MPRINT MLOGIC MERROR SYMBOLGEN;&lt;/P&gt;
&lt;P&gt;%MACRO MAI;&lt;/P&gt;
&lt;P&gt;%DO I=1 %TO 1;&lt;BR /&gt;PROC SQL;&lt;/P&gt;
&lt;P&gt;CREATE TABLE FIRST AS&lt;BR /&gt;SELECT DISTINCT(CLOSED_ON),&lt;BR /&gt;COUNT(CASE WHEN compress(AUTHORIZEDBY)="&amp;amp;AUT&amp;amp;I." THEN 1 END)AS "&amp;amp;AUT&amp;amp;I."&lt;BR /&gt;FROM INTIAL&lt;BR /&gt;GROUP BY CLOSED_ON ;&lt;/P&gt;
&lt;P&gt;QUIT;&lt;BR /&gt;%END;&lt;BR /&gt;%MEND;&lt;BR /&gt;%MAI;&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2020 14:18:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Expecting-a-name/m-p/648036#M194025</guid>
      <dc:creator>rohithverma</dc:creator>
      <dc:date>2020-05-15T14:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: Error:Expecting a name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Expecting-a-name/m-p/648038#M194027</link>
      <description>&lt;P&gt;Please post LOG as text. Pictures are hard to copy/paste/ highlight or edit.&lt;/P&gt;
&lt;P&gt;This line is pretty much syntactically incorrect as the error message indicates&lt;/P&gt;
&lt;PRE&gt;COUNT(CASE WHEN compress(AUTHORIZEDBY)="&amp;amp;AUT&amp;amp;I." THEN 1 END)AS&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt; "&amp;amp;AUT&amp;amp;I."&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;The "as &amp;lt;something&amp;gt; " for a case expression has to be the name of a variable. Since SAS variable names cannot contain " characters that is error here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you do not show where a macro variabl AUT is created or values assigned I think that you may have another logic issue even using &amp;amp;aut the way you have.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2020 14:09:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Expecting-a-name/m-p/648038#M194027</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-05-15T14:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Error:Expecting a name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Expecting-a-name/m-p/648041#M194028</link>
      <description>&lt;P&gt;Rule #1 for macro development: start with WORKING non-macro code.&lt;/P&gt;
&lt;P&gt;Get your SQL code to run for a single instance. &lt;EM&gt;Then&lt;/EM&gt; proceed to make it dynamic.&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2020 14:13:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Expecting-a-name/m-p/648041#M194028</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-15T14:13:32Z</dc:date>
    </item>
    <item>
      <title>Re: Error:Expecting a name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Expecting-a-name/m-p/648047#M194033</link>
      <description>Please find the complete prog and log now</description>
      <pubDate>Fri, 15 May 2020 14:19:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Expecting-a-name/m-p/648047#M194033</guid>
      <dc:creator>rohithverma</dc:creator>
      <dc:date>2020-05-15T14:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: Error:Expecting a name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Expecting-a-name/m-p/648048#M194034</link>
      <description>I have already developed the manual code but i am struggling while creating a macro for this</description>
      <pubDate>Fri, 15 May 2020 14:20:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Expecting-a-name/m-p/648048#M194034</guid>
      <dc:creator>rohithverma</dc:creator>
      <dc:date>2020-05-15T14:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: Error:Expecting a name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Expecting-a-name/m-p/648051#M194036</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/150852"&gt;@rohithverma&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I have already developed the manual code but i am struggling while creating a macro for this&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Post that code, so we can show you where you went wrong.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way: since you already have your data for automatizing in a dataset, all you need is a data _null_ step with call execute. No macro detour necessary.&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2020 14:23:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Expecting-a-name/m-p/648051#M194036</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-15T14:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: Error:Expecting a name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Expecting-a-name/m-p/648066#M194046</link>
      <description>i hv already posted complete code and log too</description>
      <pubDate>Fri, 15 May 2020 15:21:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Expecting-a-name/m-p/648066#M194046</guid>
      <dc:creator>rohithverma</dc:creator>
      <dc:date>2020-05-15T15:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: Error:Expecting a name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Expecting-a-name/m-p/648069#M194049</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/150852"&gt;@rohithverma&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;i hv already posted complete code and log too&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No. You only posted your failing attempt at macrotizing the code. I want you to show the non-macro code.&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2020 15:24:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Expecting-a-name/m-p/648069#M194049</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-15T15:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Error:Expecting a name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Expecting-a-name/m-p/648084#M194060</link>
      <description>&lt;P&gt;&amp;amp;AUT&amp;amp;I. is always wrong.&amp;nbsp; The right version depends on seeing what the non-macro code should look like.&amp;nbsp; Two possibilities, either of which could be correct (and possibly one used in one place in the macro, and the other in another place):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AUT&amp;amp;I.&lt;/P&gt;
&lt;P&gt;&amp;amp;&amp;amp;AUT&amp;amp;I.&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2020 16:20:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Expecting-a-name/m-p/648084#M194060</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-05-15T16:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: Error:Expecting a name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Expecting-a-name/m-p/648099#M194069</link>
      <description>&lt;P&gt;If you want the value of AUT5 when I=5 then use&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;amp;&amp;amp;AUT&amp;amp;I&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to name the variable AUTnnn where nnn is the value of the macro variable I then just use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;AUT&amp;amp;i&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;without the quotes.&amp;nbsp; If you want PROC SQL to treat a quoted string in that location as a variable name then you need to add the DQUOTE=ANSI option to the PROC SQL statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your initial SQL is working way too hard.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select distinct authorizedby into :aut1- from intial;
%let cnt=&amp;amp;sqlobs;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your CASE statement logic does not match how you created the macro variables.&amp;nbsp; If you want to compare &amp;amp;AUT1 to the result of using the COMPRESS() function on AUTHORIZEDBY then you should include the COMPRESS() function in the code that generates the macro variables.&amp;nbsp; Might be better to just add the quotes into the macro variable when they are created. Include the TRIM() function to avoid storing the unneeded trailing spaces into the quoted string that is stored into the macro variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select distinct quote(trim(authorizedby)) into :aut1- from intial;
...
CASE WHEN AUTHORIZEDBY=&amp;amp;&amp;amp;AUT&amp;amp;I THEN 1 END&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2020 16:59:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Expecting-a-name/m-p/648099#M194069</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-05-15T16:59:15Z</dc:date>
    </item>
  </channel>
</rss>

