Hi,
I replaced all the macro calls with put statements and the macro variables are resolving. I had to hard code a couple of values and I changed the beginning part since it seemed unnecessarily complicated. Hope this helps a bit.
data grouch; prvorg = 'org1'; output; prvorg = 'org2'; output; prvorg = 'org2'; output; run;
%macro hosp_loop(); /* Hospital counts */ /* proc sort data=grouch out=porgs(keep=prvorg) nodupkey; by prvorg; run;
data porgcnt; set porgs; IF PRVORG = " " THEN DELETE; cnt+1; run;
proc sql; create table hospcnt as select a.*, b.cnt, max(cnt) as maxnum from porgs a left join porgcnt b on a.prvorg=b.prvorg; quit;
data _null_; set hospcnt; call symput('maxcnt',maxnum); run; */
proc freq data = grouch noprint; table prvorg / out = hospcnt (rename = (count = cnt) drop = percent); run;
proc sql; select max(cnt) into :maxcnt from hospcnt; quit;
%put &maxcnt;
/* Pull data from GROUCHBYEFFPER table */ %put ANA055_datapull; /* Report data for all hospitals for both Report 3 and Report 4 (creates detail_hosp_rptX & detail_hf_rptX) */ %put ANA055_datapull3; %put ANA055_datapull4;
%global prvorg effdt; %let effdt = effdt; /* made up value */ %let drv7 = drv7; /* made up value */
/* loop to go through all hospitals */ %macro hosrep(); %do j= 1 %to &maxcnt; data _null_; set hospcnt; if cnt=&j; *call symput('prvorg',trim(left(prvorg))); call symputx('prvorg',prvorg); run;
%put j=&j., prvorg=&prvorg;
/* Report data for selected hosital (creates tables report_output_rptX) */ %put ANA055_reportdata_3(&prvorg); %put ANA055_reportdata_4(&prvorg); /* Create Report 3 */ %put pdf_head(l,y,8,&drv7.\ANA05501\current,ANA05501_30_&prvorg._A); %put ANA055_report_3; %put pdf_tail(&effdt);
/* Create Report 4 */ %put pdf_head(l,y,8,&drv7.\ANA05501\current,ANA05501_30_&prvorg._B); %put ANA055_report_4; %put pdf_tail(&effdt); %end; %mend hosrep;
%if &maxcnt=0 %then %do; %goto skip1; %end; %else %hosrep; %skip1:;
%mend hosp_loop; %hosp_loop;
... View more