<?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: Regarding Macro Error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Regarding-Macro-Error/m-p/227267#M40929</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I replaced all the macro calls with put statements and the macro variables are resolving. &amp;nbsp;I had to hard code a couple of values and I changed the beginning part since it seemed unnecessarily complicated. &amp;nbsp;Hope this helps a bit.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data grouch;&lt;BR /&gt; prvorg = 'org1'; output;&lt;BR /&gt; prvorg = 'org2'; output;&lt;BR /&gt; prvorg = 'org2'; output;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%macro hosp_loop();&lt;BR /&gt;/* Hospital counts */&lt;BR /&gt;/*&lt;BR /&gt;proc sort data=grouch out=porgs(keep=prvorg) nodupkey;&lt;BR /&gt;by prvorg;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data porgcnt;&lt;BR /&gt;set porgs;&lt;BR /&gt;IF PRVORG = " " THEN DELETE;&lt;BR /&gt;cnt+1;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table hospcnt as&lt;BR /&gt;select a.*, b.cnt, max(cnt) as maxnum&lt;BR /&gt;from porgs a left join porgcnt b&lt;BR /&gt;on a.prvorg=b.prvorg;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;set hospcnt;&lt;BR /&gt;call symput('maxcnt',maxnum);&lt;BR /&gt;run;&lt;BR /&gt;*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data = grouch noprint;&lt;BR /&gt; table prvorg / out = hospcnt (rename = (count = cnt) drop = percent);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt; select max(cnt) into :maxcnt&lt;BR /&gt; from hospcnt;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;maxcnt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;/* Pull data from GROUCHBYEFFPER table */&lt;BR /&gt;%put ANA055_datapull;&lt;BR /&gt;/* Report data for all hospitals for both Report 3 and Report 4 (creates detail_hosp_rptX &amp;amp; detail_hf_rptX) */&lt;BR /&gt;%put ANA055_datapull3;&lt;BR /&gt;%put ANA055_datapull4;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%global prvorg effdt;&lt;BR /&gt;%let effdt = effdt; /* made up value */ &lt;BR /&gt;%let drv7 = drv7; /* made up value */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* loop to go through all hospitals */&lt;BR /&gt;%macro hosrep();&lt;BR /&gt; &lt;BR /&gt;%do j= 1 %to &amp;amp;maxcnt;&lt;BR /&gt; data _null_;&lt;BR /&gt; set hospcnt;&lt;BR /&gt; if cnt=&amp;amp;j;&lt;BR /&gt; *call symput('prvorg',trim(left(prvorg)));&lt;BR /&gt; call symputx('prvorg',prvorg);&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put j=&amp;amp;j., prvorg=&amp;amp;prvorg;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* Report data for selected hosital (creates tables report_output_rptX) */&lt;BR /&gt; %put ANA055_reportdata_3(&amp;amp;prvorg);&lt;BR /&gt; %put ANA055_reportdata_4(&amp;amp;prvorg);&lt;BR /&gt; /* Create Report 3 */&lt;BR /&gt; %put pdf_head(l,y,8,&amp;amp;drv7.\ANA05501\current,ANA05501_30_&amp;amp;prvorg._A);&lt;BR /&gt; %put ANA055_report_3;&lt;BR /&gt; %put pdf_tail(&amp;amp;effdt);&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; /* Create Report 4 */&lt;BR /&gt; %put pdf_head(l,y,8,&amp;amp;drv7.\ANA05501\current,ANA05501_30_&amp;amp;prvorg._B);&lt;BR /&gt; %put ANA055_report_4;&lt;BR /&gt; %put pdf_tail(&amp;amp;effdt);&lt;BR /&gt;%end;&lt;BR /&gt;%mend hosrep;&lt;/P&gt;
&lt;P&gt;%if &amp;amp;maxcnt=0 %then %do;&lt;BR /&gt;%goto skip1;&lt;BR /&gt;%end;&lt;BR /&gt;%else %hosrep;&lt;BR /&gt;%skip1:;&lt;/P&gt;
&lt;P&gt;%mend hosp_loop;&lt;BR /&gt;%hosp_loop;&lt;/P&gt;</description>
    <pubDate>Fri, 25 Sep 2015 13:48:43 GMT</pubDate>
    <dc:creator>evp000</dc:creator>
    <dc:date>2015-09-25T13:48:43Z</dc:date>
    <item>
      <title>Regarding Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regarding-Macro-Error/m-p/227163#M40894</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Good Afternoon&amp;nbsp;All,&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;I&amp;nbsp;am running the below Macro code and getting some errors.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; hospcnt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;call&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; symput(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'maxcnt'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;,maxnum);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%put&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;maxcnt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;/* loop to go through all hospitals */&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;%macro&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; hosrep();&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; j= &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;maxcnt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;set hospcnt;&lt;/P&gt;&lt;P&gt;if cnt=&amp;amp;j;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;call symput(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'i'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;,trim(left(prvorg)));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data report1;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;set &amp;amp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;save.&lt;STRONG&gt;.p&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;rocrpt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;if prvorg=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"&amp;amp;i"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;%mend&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; hosrep;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;Error:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;MPRINT(HOSP_LOOP):&amp;nbsp;&amp;nbsp; data _null_;&lt;BR /&gt;MPRINT(HOSP_LOOP):&amp;nbsp;&amp;nbsp; set hospcnt;&lt;BR /&gt;MPRINT(HOSP_LOOP):&amp;nbsp;&amp;nbsp; call symput('maxcnt',maxnum);&lt;BR /&gt;MPRINT(HOSP_LOOP):&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3:179&amp;nbsp;&amp;nbsp;&lt;BR /&gt;NOTE: There were 91 observations read from the data set WORK.HOSPCNT.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; user cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; system cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; memory&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 189.17k&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OS Memory&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 26480.00k&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Timestamp&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 09/24/2015 12:37:28 PM&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;SYMBOLGEN:&amp;nbsp; Macro variable MAXCNT resolves to&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 91&lt;BR /&gt;91&lt;BR /&gt;SYMBOLGEN:&amp;nbsp; Macro variable MAXCNT resolves to&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 91&lt;BR /&gt;SYMBOLGEN:&amp;nbsp; Macro variable MAXCNT resolves to&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 91&lt;BR /&gt;NOTE: Line generated by the invoked macro "HOSREP".&lt;BR /&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data _null_;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set hospcnt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if cnt=&amp;amp;j;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput('i',trim(left(prvorg)));&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data report1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22&lt;BR /&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; !&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set &amp;amp;save..procrpt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if prvorg="&amp;amp;i";&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data report2;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set &amp;amp;save..percents;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;BR /&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; ! prvorg="&amp;amp;i";&lt;BR /&gt;MPRINT(HOSREP):&amp;nbsp;&amp;nbsp; data _null_;&lt;BR /&gt;MPRINT(HOSREP):&amp;nbsp;&amp;nbsp; set hospcnt;&lt;BR /&gt;WARNING: Apparent symbolic reference J not resolved.&lt;BR /&gt;MPRINT(HOSREP):&amp;nbsp;&amp;nbsp; if cnt=&amp;amp;j;&lt;BR /&gt;MPRINT(HOSREP):&amp;nbsp;&amp;nbsp; call symput('i',trim(left(prvorg)));&lt;BR /&gt;MPRINT(HOSREP):&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a datetime constant, a missing value, bitstring, INPUT, PUT.&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.13 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; user cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; system cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; memory&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 125.64k&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OS Memory&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 26480.00k&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Timestamp&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 09/24/2015 12:37:28 PM&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MPRINT(HOSREP):&amp;nbsp;&amp;nbsp; data report1;&lt;BR /&gt;SYMBOLGEN:&amp;nbsp; Macro variable SAVE resolves to work&lt;BR /&gt;MPRINT(HOSREP):&amp;nbsp;&amp;nbsp; set work.procrpt;&lt;BR /&gt;WARNING: Apparent symbolic reference I not resolved.&lt;BR /&gt;MPRINT(HOSREP):&amp;nbsp;&amp;nbsp; if prvorg="&amp;amp;i";&lt;BR /&gt;MPRINT(HOSREP):&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2015 19:21:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regarding-Macro-Error/m-p/227163#M40894</guid>
      <dc:creator>raveena</dc:creator>
      <dc:date>2015-09-24T19:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regarding-Macro-Error/m-p/227175#M40898</link>
      <description>&lt;P&gt;Looks like it would be relatively easy to run the code without the macro, replace &amp;amp;j with 1 and see what you get.&amp;nbsp; That troubleshooting step will make everything a lot easier.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2015 19:46:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regarding-Macro-Error/m-p/227175#M40898</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-09-24T19:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regarding-Macro-Error/m-p/227177#M40899</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I couldn't run all your code because I don't know what's in&amp;nbsp;&amp;amp;save..procrpt but this code works. &amp;nbsp;It may be just the difference of using call syputx rather than symput. &amp;nbsp;Now that symputx exists there doesn't seem to be any reason to use symput.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002295697.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002295697.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data hospcnt;&lt;BR /&gt; maxnum = 2; &lt;BR /&gt; cnt = 1; prvorg = 'org1'; output;&lt;BR /&gt; cnt = 2; prvorg = 'org2'; output;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt; set hospcnt;&lt;BR /&gt; call symputx('maxcnt',maxnum);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;maxcnt;&lt;/P&gt;
&lt;P&gt;%macro hosrep();&lt;BR /&gt;%do j = 1 %to &amp;amp;maxcnt;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt; set hospcnt;&lt;BR /&gt; if cnt=&amp;amp;j;&lt;BR /&gt; call symput('i',prvorg);&lt;BR /&gt;run;&lt;BR /&gt;%put i = &amp;gt;&amp;amp;i&amp;lt;;&lt;/P&gt;
&lt;P&gt;%end;&lt;BR /&gt;%mend hosrep;&lt;BR /&gt;%hosrep;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2015 19:54:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regarding-Macro-Error/m-p/227177#M40899</guid>
      <dc:creator>evp000</dc:creator>
      <dc:date>2015-09-24T19:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regarding-Macro-Error/m-p/227187#M40902</link>
      <description>Here's a guess, but an educated guess. There are several signs in your results that indicate you had to simplify the code when presenting the question for the message board. I believe that a key piece was simplified, and is actually different than what you posted: %do j=1 %to &amp;amp;maxcnt; I suspect that the actual macro variable used to loop was not named J but something else. Is that something you can check? If that's not it, are you able to post the first few lines of the actual (not simplified) code beginning with %macro hosrep?</description>
      <pubDate>Thu, 24 Sep 2015 21:17:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regarding-Macro-Error/m-p/227187#M40902</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-09-24T21:17:13Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regarding-Macro-Error/m-p/227212#M40904</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here attached the entire macro loop for your reference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; hosp_loop();&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;/* Hospital counts */&lt;/P&gt;&lt;P&gt;proc sort data=grouch out=porgs(keep=prvorg) nodupkey;&lt;/P&gt;&lt;P&gt;by prvorg;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data porgcnt;&lt;/P&gt;&lt;P&gt;set porgs;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;IF PRVORG = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;" "&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; THEN DELETE;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;cnt+&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table hospcnt as&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;select &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;a.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;*, b.cnt, max(cnt) as maxnum&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;from porgs a left join porgcnt b&lt;/P&gt;&lt;P&gt;on a.prvorg=b.prvorg;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;set hospcnt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;call symput(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'maxcnt'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;,maxnum);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%put&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;maxcnt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;/* Pull data from GROUCHBYEFFPER table */&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;ANA055_datapull&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;/* Report data for all hospitals for both Report 3 and Report 4 (creates detail_hosp_rptX &amp;amp; detail_hf_rptX) */&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;ANA055_datapull3&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;ANA055_datapull4&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;/* loop to go through all hospitals */&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%global&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; prvorg;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;%macro&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; hosrep();&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; j= &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;maxcnt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;set hospcnt;&lt;/P&gt;&lt;P&gt;if cnt=&amp;amp;j;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;call symput(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'prvorg'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;,trim(left(prvorg))); &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;/* Report data for selected hosital (creates tables report_output_rptX) */&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;ANA055_reportdata_3&lt;/I&gt;&lt;/STRONG&gt;(&amp;amp;prvorg);&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;ANA055_reportdata_4&lt;/I&gt;&lt;/STRONG&gt;(&amp;amp;prvorg);&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;/* Create Report 3 */&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;%&lt;STRONG&gt;&lt;I&gt;pdf_head&lt;/I&gt;&lt;/STRONG&gt;(l,y,&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;8&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;,&amp;amp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;drv7.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;\ANA05501\current,ANA05501_30_&amp;amp;prvorg._A); &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;ANA055_report_3&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;pdf_tail&lt;/I&gt;&lt;/STRONG&gt;(&amp;amp;effdt);&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;/* Create Report 4 */&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;%&lt;STRONG&gt;&lt;I&gt;pdf_head&lt;/I&gt;&lt;/STRONG&gt;(l,y,&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;8&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;,&amp;amp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;drv7.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;\ANA05501\current,ANA05501_30_&amp;amp;prvorg._B); &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;ANA055_report_4&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;pdf_tail&lt;/I&gt;&lt;/STRONG&gt;(&amp;amp;effdt);&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;%mend&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; hosrep;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%if&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;maxcnt=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%then&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%goto&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; skip1;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%else&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; %&lt;STRONG&gt;&lt;I&gt;hosrep&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%skip1:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; hosp_loop;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2015 03:02:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regarding-Macro-Error/m-p/227212#M40904</guid>
      <dc:creator>raveena</dc:creator>
      <dc:date>2015-09-25T03:02:54Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regarding-Macro-Error/m-p/227217#M40905</link>
      <description>You shouldn't nest macros like that...I would suggest extracting them into separate macros and seein if that helps for starters.</description>
      <pubDate>Fri, 25 Sep 2015 03:54:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regarding-Macro-Error/m-p/227217#M40905</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-09-25T03:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regarding-Macro-Error/m-p/227267#M40929</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I replaced all the macro calls with put statements and the macro variables are resolving. &amp;nbsp;I had to hard code a couple of values and I changed the beginning part since it seemed unnecessarily complicated. &amp;nbsp;Hope this helps a bit.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data grouch;&lt;BR /&gt; prvorg = 'org1'; output;&lt;BR /&gt; prvorg = 'org2'; output;&lt;BR /&gt; prvorg = 'org2'; output;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%macro hosp_loop();&lt;BR /&gt;/* Hospital counts */&lt;BR /&gt;/*&lt;BR /&gt;proc sort data=grouch out=porgs(keep=prvorg) nodupkey;&lt;BR /&gt;by prvorg;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data porgcnt;&lt;BR /&gt;set porgs;&lt;BR /&gt;IF PRVORG = " " THEN DELETE;&lt;BR /&gt;cnt+1;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table hospcnt as&lt;BR /&gt;select a.*, b.cnt, max(cnt) as maxnum&lt;BR /&gt;from porgs a left join porgcnt b&lt;BR /&gt;on a.prvorg=b.prvorg;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;set hospcnt;&lt;BR /&gt;call symput('maxcnt',maxnum);&lt;BR /&gt;run;&lt;BR /&gt;*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data = grouch noprint;&lt;BR /&gt; table prvorg / out = hospcnt (rename = (count = cnt) drop = percent);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt; select max(cnt) into :maxcnt&lt;BR /&gt; from hospcnt;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;maxcnt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;/* Pull data from GROUCHBYEFFPER table */&lt;BR /&gt;%put ANA055_datapull;&lt;BR /&gt;/* Report data for all hospitals for both Report 3 and Report 4 (creates detail_hosp_rptX &amp;amp; detail_hf_rptX) */&lt;BR /&gt;%put ANA055_datapull3;&lt;BR /&gt;%put ANA055_datapull4;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%global prvorg effdt;&lt;BR /&gt;%let effdt = effdt; /* made up value */ &lt;BR /&gt;%let drv7 = drv7; /* made up value */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* loop to go through all hospitals */&lt;BR /&gt;%macro hosrep();&lt;BR /&gt; &lt;BR /&gt;%do j= 1 %to &amp;amp;maxcnt;&lt;BR /&gt; data _null_;&lt;BR /&gt; set hospcnt;&lt;BR /&gt; if cnt=&amp;amp;j;&lt;BR /&gt; *call symput('prvorg',trim(left(prvorg)));&lt;BR /&gt; call symputx('prvorg',prvorg);&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put j=&amp;amp;j., prvorg=&amp;amp;prvorg;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* Report data for selected hosital (creates tables report_output_rptX) */&lt;BR /&gt; %put ANA055_reportdata_3(&amp;amp;prvorg);&lt;BR /&gt; %put ANA055_reportdata_4(&amp;amp;prvorg);&lt;BR /&gt; /* Create Report 3 */&lt;BR /&gt; %put pdf_head(l,y,8,&amp;amp;drv7.\ANA05501\current,ANA05501_30_&amp;amp;prvorg._A);&lt;BR /&gt; %put ANA055_report_3;&lt;BR /&gt; %put pdf_tail(&amp;amp;effdt);&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; /* Create Report 4 */&lt;BR /&gt; %put pdf_head(l,y,8,&amp;amp;drv7.\ANA05501\current,ANA05501_30_&amp;amp;prvorg._B);&lt;BR /&gt; %put ANA055_report_4;&lt;BR /&gt; %put pdf_tail(&amp;amp;effdt);&lt;BR /&gt;%end;&lt;BR /&gt;%mend hosrep;&lt;/P&gt;
&lt;P&gt;%if &amp;amp;maxcnt=0 %then %do;&lt;BR /&gt;%goto skip1;&lt;BR /&gt;%end;&lt;BR /&gt;%else %hosrep;&lt;BR /&gt;%skip1:;&lt;/P&gt;
&lt;P&gt;%mend hosp_loop;&lt;BR /&gt;%hosp_loop;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2015 13:48:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regarding-Macro-Error/m-p/227267#M40929</guid>
      <dc:creator>evp000</dc:creator>
      <dc:date>2015-09-25T13:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regarding-Macro-Error/m-p/227306#M40944</link>
      <description>&lt;P&gt;I agree with Reeza, you should not imbed macro definitions within each other. Another tool that may help is create a file that contains the code generated by your macro code. Then you can run the code as it would run after generated by the macro facility. All you have to do is run the following two lines before you run the macro:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;options&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;mprint&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;mfile&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;filename&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; mprint &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'path'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;where path is a fully qualified path to a file which will contain the code the macro will generate.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2015 17:06:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regarding-Macro-Error/m-p/227306#M40944</guid>
      <dc:creator>michelle_delaurentis_sas_com</dc:creator>
      <dc:date>2015-09-25T17:06:35Z</dc:date>
    </item>
  </channel>
</rss>

