<?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: Using  Call Execute With Nliteral Together in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/461413#M117378</link>
    <description>&lt;P&gt;Will this change the value of the department that I am sending?&amp;nbsp; I’m trying to send one department at a time so that I can run a where clause in the macro.&lt;/P&gt;</description>
    <pubDate>Thu, 10 May 2018 20:08:48 GMT</pubDate>
    <dc:creator>DavidPhillips2</dc:creator>
    <dc:date>2018-05-10T20:08:48Z</dc:date>
    <item>
      <title>Using  Call Execute With Nliteral Together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/461402#M117371</link>
      <description>&lt;P&gt;I need to pass a value with an apostrophe into a marco using that I need to call using call execute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is wrong with my syntax that is causing:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table departmentList as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select distinct nliteral(department) from mytable&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; _null_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set departmentList;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; call execute(cats('%callStudentBody(',nliteral(department),');'));&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: The NLITERAL function cannot convert a blank string to a valid n-literal.&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 19:11:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/461402#M117371</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-05-10T19:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using  Call Execute With Nliteral Together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/461403#M117372</link>
      <description>&lt;P&gt;i think you can't have a var name&lt;STRONG&gt;&amp;nbsp;-- &amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;' 'n&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;if not missing(department)&lt;/STRONG&gt; &lt;/EM&gt;then&amp;nbsp;&amp;nbsp; call execute(cats('%callStudentBody(',nliteral(department),');'));&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 19:14:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/461403#M117372</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-10T19:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: Using  Call Execute With Nliteral Together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/461404#M117373</link>
      <description>&lt;P&gt;novinosrin, I think you are right.&amp;nbsp; I am modifying my code to remove the null.&amp;nbsp; Then I will likely receive the error message I was thinking it was about for the apostrophe.&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 19:17:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/461404#M117373</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-05-10T19:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using  Call Execute With Nliteral Together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/461408#M117374</link>
      <description>&lt;P&gt;This is the type of error I meant to work though:&lt;/P&gt;
&lt;P&gt;if not missing(department) then&amp;nbsp; &amp;nbsp;call execute(cats('%callStudentBody(',nliteral(department),');'));&lt;/P&gt;
&lt;P&gt;ERROR: Literal contains unmatched quote&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 19:52:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/461408#M117374</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-05-10T19:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using  Call Execute With Nliteral Together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/461409#M117375</link>
      <description>&lt;P&gt;An easy fix if acceptable is keep alpha and digits only and then nliteral and call execute&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if not missing(department) then&amp;nbsp; &amp;nbsp;call execute(cats('%callStudentBody(',nliteral(department),');'));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;modified to:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;compress(department, ,'kad');&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;if not missing(department) then&amp;nbsp; &amp;nbsp;call execute(cats('%callStudentBody(',nliteral(compress(department, ,'kad')),');'));&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 20:04:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/461409#M117375</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-10T20:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using  Call Execute With Nliteral Together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/461412#M117377</link>
      <description>&lt;P&gt;Maybe exclude the possibility of blank value prior:&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table departmentList as
   select distinct nliteral(department) from mytable
   where not missing(department)
   ;
quit;&lt;/PRE&gt;
&lt;P&gt;I find that sometimes working with Call execute it is better to create a longish string variable to build the argument for call execute so I can check the resolution of the string functions with the added complication of the actual call execute and especially if macro calls are involved.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Such as&lt;/P&gt;
&lt;PRE&gt;data work.junk;
   department='some dept'; 
   length str $ 200;
   str =cats('%callStudentBody(',nliteral(department),')');
   /*call execute(str);*/
run;&lt;/PRE&gt;
&lt;P&gt;I can look at STR and see if the call is as desired. Then test it one time in this case by uncommenting the call execute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 20:06:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/461412#M117377</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-10T20:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: Using  Call Execute With Nliteral Together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/461413#M117378</link>
      <description>&lt;P&gt;Will this change the value of the department that I am sending?&amp;nbsp; I’m trying to send one department at a time so that I can run a where clause in the macro.&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 20:08:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/461413#M117378</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-05-10T20:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using  Call Execute With Nliteral Together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/461414#M117379</link>
      <description>&lt;P&gt;You are right. I am sorry. Without knowing the data, i should be recommending such a thing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How about this gamble with %superq&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if not missing(department) then   call execute %nrstr(cats('%callStudentBody(',%superq(nliteral(department)),');'));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I would request&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;to opine on the %superQ above and correct if he doesn;t mind&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDITED further at 3:24 CDT:&lt;/P&gt;&lt;P&gt;Ok, the above won't work i think.&amp;nbsp;&lt;/P&gt;&lt;P&gt;At the time of execution of %callstudentbody macro , the macro processor with resolve some macro variable to the nliteral department value. That macro reference will prolly be something like&amp;nbsp; &amp;amp;dept.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe that's when the unmatched quote is perhaps causing the problem. If this is right, the %superq will be very helpful to change &amp;amp;dept to %superq(dept);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Either way, best is to wait for responses from others&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 20:23:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/461414#M117379</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-05-10T20:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using  Call Execute With Nliteral Together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/461428#M117387</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/5059"&gt;@DavidPhillips2&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Will this change the value of the department that I am sending?&amp;nbsp; I’m trying to send one department at a time so that I can run a where clause in the macro.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you show us an example of a use of the macro without call execute that works as intended.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or the code of the macro called and maybe some example data.&lt;/P&gt;
&lt;P&gt;Or at least the macro where clause and some surrounding code.&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;I am not a fan of letting a function create a variable name that I haven't checked to create valid values.&lt;/P&gt;
&lt;P&gt;And since you seem to be creating multiple variable names perhaps this goes back at root to data structure problem where you should have a single variable "department" that takes on the values of the department names like "Sporting goods" or "Women's Clothing" and then process with a BY group process to create the results for each department.&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 21:58:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/461428#M117387</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-10T21:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using  Call Execute With Nliteral Together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/462722#M117840</link>
      <description>&lt;P&gt;I'm trying to figure out how to pass the nliteral correctly between macros.&lt;BR /&gt;The department list contains the value: Arts-Qatar Dean's Office&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/*set the where clauses that are used in the body.*/


%macro setDepartmentClause(curDepartment);
%let cdepartmentClause = %str(and c_department_desc =&amp;amp;curDepartment);
%mend;



/*creates the acutal report. The tables for the report are created using dynamic where clauses*/
%macro Body(curDepartment);
%setDepartmentClause(&amp;amp;curDepartment);

/*here i'm running into "ERROR: Literal contains unmatched quote." because I am passing the nliteral incorrectly*/
%mend;



/*call the macro body and loop it with each department */
data _null_;
set departmentList;
length str $ 200;
str =cats('%Body(',nliteral(department),')');
call execute(str);
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 14:31:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/462722#M117840</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-05-16T14:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: Using  Call Execute With Nliteral Together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/462734#M117843</link>
      <description>&lt;P&gt;I had a put statement that threw the error i just posted.&amp;nbsp; I took it out to look at the errors around the dynamic where clause and noticed it was a little unexpected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The part of the dynamic where clause I am focusing on is:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and department ="Arts-Qatar Dean's Office"N&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;with the message:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: The following columns were not found in the contributing tables: Arts-Qatar Dean''s Office.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure why the log states that the quoted text is a column.&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 15:05:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/462734#M117843</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-05-16T15:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using  Call Execute With Nliteral Together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/463400#M118056</link>
      <description>&lt;P&gt;Maybe this will make more sense.&amp;nbsp; I'm trying to run this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;PRE&gt;%Global cdepartmentClause;

proc sql;
	create table departmentList (department varchar(100));
	insert into departmentList (department) values ("Arts-Qatar Dean's Office");

	create table enrollment (c_department_desc varchar(100));
	insert into enrollment (c_department_desc) values ("Arts-Qatar Dean's Office");
quit;

/*set the where clauses that are used in the body.*/
%macro setDepartmentClause(curDepartment);
	%let cdepartmentClause = %str(c_department_desc =&amp;amp;curDepartment);
%mend;

/*creates the acutal report. The tables for the report are created using dynamic where clauses*/
%macro Body(curDepartment);
	%setDepartmentClause(&amp;amp;curDepartment);
	data outputResults; set enrollment;
	/*here i'm running into "ERROR: Literal contains unmatched quote." because I am passing the nliteral incorrectly*/
		where &amp;amp;cdepartmentClause.;
	run;
%mend;

/*call the macro body and loop it with each department */
data _null_;
set departmentList;
length str $ 200;
str =cats('%Body(',nliteral(department),')');
call execute(str);
run;&lt;/PRE&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Fri, 18 May 2018 17:10:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/463400#M118056</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-05-18T17:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: Using  Call Execute With Nliteral Together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/463404#M118058</link>
      <description>&lt;P&gt;SAS replied with this solution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%Global cdepartmentClause;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table departmentList (department varchar(100));&lt;/P&gt;
&lt;P&gt;insert into departmentList (department) values ("Arts-Qatar Dean's Office");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;create table enrollment (c_department_desc varchar(100));&lt;/P&gt;
&lt;P&gt;insert into enrollment (c_department_desc) values ("Arts-Qatar Dean's Office");&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*set the where clauses that are used in the body.*/&lt;/P&gt;
&lt;P&gt;%macro setDepartmentClause(curDepartment);&lt;/P&gt;
&lt;P&gt;%let cdepartmentClause =%str(c_department_desc ="&amp;amp;curDepartment");&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*creates the acutal report. The tables for the report are created using dynamic where clauses*/&lt;/P&gt;
&lt;P&gt;%macro Body(curDepartment);&lt;/P&gt;
&lt;P&gt;%setDepartmentClause(&amp;amp;curDepartment);&lt;/P&gt;
&lt;P&gt;data outputResults; set enrollment;&lt;/P&gt;
&lt;P&gt;/*here i'm running into "ERROR: Literal contains unmatched quote." because I am passing the nliteral incorrectly*/&lt;/P&gt;
&lt;P&gt;where &amp;amp;cdepartmentClause;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*call the macro body and loop it with each department */&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;set departmentList;&lt;/P&gt;
&lt;P&gt;length str $ 200;&lt;/P&gt;
&lt;P&gt;str =cats('%Body(%bquote(',department,'))');&lt;/P&gt;
&lt;P&gt;call execute(str);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 18 May 2018 17:40:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/463404#M118058</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-05-18T17:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using  Call Execute With Nliteral Together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/464900#M118547</link>
      <description>&lt;P&gt;A complication occurs when the department has &amp;amp; in the name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &lt;BR /&gt; &amp;amp;curDepartment eq&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%Global cdepartmentClause;

proc sql;

create table departmentList (department varchar(100));

insert into departmentList (department) values ("Counseling &amp;amp; Special Education");

&amp;nbsp;

create table enrollment (c_department_desc varchar(100));

insert into enrollment (c_department_desc) values ("Counseling &amp;amp; Special Education");

quit;

&amp;nbsp;

/*set the where clauses that are used in the body.*/ 
%macro setDepartmentClause(curDepartment); 
/*I need to check if the department is blank for looping purposes*/
%if &amp;amp;curDepartment eq %then %do;
%let cdepartmentClause = %str();
%end;
%else %do;
%let cdepartmentClause =%str(c_department_desc ="&amp;amp;curDepartment");
%end; 
%mend;

&amp;nbsp;

/*creates the acutal report. The tables for the report are created using dynamic where clauses*/

%macro Body(curDepartment);

%setDepartmentClause(&amp;amp;curDepartment);

data outputResults; set enrollment;



where &amp;amp;cdepartmentClause;

run;

%mend;

%Body();

/*call the macro body and loop it with each department */

data _null_;

set departmentList;

length str $ 200;

str =cats('%Body(%bquote(',department,'))');

call execute(str);

run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 May 2018 20:29:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-Call-Execute-With-Nliteral-Together/m-p/464900#M118547</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-05-24T20:29:38Z</dc:date>
    </item>
  </channel>
</rss>

