<?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 macro variables in macro not resolving in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-variables-in-macro-not-resolving/m-p/735697#M229178</link>
    <description>&lt;P&gt;Hi, the problem my code is having is that the min_yr and max_yr variables within the macro aren't resolving. Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;CODE&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let run_dt = %sysfunc(today(), yymmddn.) ;
%let issuer_ids = 80473/25768 ; /*This is used for the status file names.*/

libname wrk "/sasuser/mclevx1/workspace";
libname kb "/sasuser/bailkx4/wrk/edge/dat/med" ;

libname aca_enr  "/au/test/aca/dat/enr";
libname ras_repc "/au/test/ras_repc/dat";

/*EDGE SUPP IMPORT*/
%let edg_sup = /sasuser/bailkx4/wrk/edge/dat/sup/ ;
libname edg_sup "&amp;amp;edg_sup." ;

%let edg_med = /au/test/edge/dat/med/ ;
libname edg_med "&amp;amp;edg_med." ;

/* Filenames to import */
DATA fl_nms ;
	input fl_nm $30. ;
	datalines ;
supp_thrombo
supp_mdaudit
supp_immuno
supp_deact_imo
;
RUN ;

%macro impt(nm) ;
	
	DATA &amp;amp;nm. ; 
	infile "&amp;amp;edg_sup.&amp;amp;nm..txt" delimiter = '09'x MISSOVER DSD lrecl=32767 firstobs = 2 ;
		informat csr_nbr $9. ;
		informat clm_nbr $13. ;
		informat dos anydtdte10. ;
		informat dx_code $10. ;
		informat status $1. ;
		format dos mmddyy10. ;
		input csr_nbr
			clm_nbr
			dos
			dx_code
			status ; 
		tmp = compress(tranwrd(dx_code,".","")) ; /*Remove periods from dx codes*/
		drop dx_code ;
		rename tmp = dx_code ;
	RUN ;
	
	/* Determine the year range */
	PROC SQL noprint ;
		select max(min(yrs),2016), max(yrs) /*2014 and 2015 claims will need to be manually reviewed*/
		into :&lt;FONT color="#FF0000"&gt;min_yr &lt;/FONT&gt;, :&lt;FONT color="#FF0000"&gt;max_yr&lt;/FONT&gt; 
		from 
			(
				select distinct year(dos) as yrs
				from &amp;amp;nm.
				where not(missing(dos))
			) ;
	QUIT ;
	
	%do i = &amp;amp;&amp;amp;min_yr. %to &amp;amp;&amp;amp;max_yr. ;

		%let _len_j = %eval(%sysfunc(countc(&amp;amp;issuer_ids.,/)) + 1) ;

		%do jj = 1 %to &amp;amp;_len_j. ;
			
			%let issuer = %scan(&amp;amp;issuer_ids.,&amp;amp;jj.) ;

			proc sql ;
			create table tmp_&amp;amp;nm._&amp;amp;i._&amp;amp;issuer. as 
			select distinct a.*
			from &amp;amp;nm. a 
			inner join kb.edg_med_&amp;amp;i._&amp;amp;issuer. b /*submitted edge data*/
				on a.clm_nbr = b.edg_claim_id
			where b.au_lst_adj = 'Y' and year(dos) = &amp;amp;i.
			order by a.csr_nbr
				,a.clm_nbr
				,a.dos
				,a.dx_code ;
			quit ;
			
			/*Prepare data to submit to RADA for FIU*/
			DATA edg_sup.&amp;amp;nm._&amp;amp;i._&amp;amp;issuer. (keep = csr_nbr clm_nbr dos dx_code status)
				edg_sup.&amp;amp;nm._fiu_&amp;amp;i._&amp;amp;issuer. (keep = region_code mrn dos clm_nbr purpose diagnosis_code rename = (clm_nbr = edg_claim_id) );
			  SET tmp_&amp;amp;nm._&amp;amp;i._&amp;amp;issuer. ;
				
				region_code = 'WA' ;
				
				mrn = input(csr_nbr,9.) ; 
				
				format purpose $5. ;
				if status = "A" then do ;
					purpose = "ADD" ;
				end ;
				else purpose = "DELDX" ;

				diagnosis_code = dx_code ;
				
			RUN ;

			/*Export FIU data file*/
			proc export data = edg_sup.&amp;amp;nm._&amp;amp;i._fiu_&amp;amp;issuer.
			  outfile = "&amp;amp;edg_sup.edge_&amp;amp;nm._&amp;amp;i._fiu_&amp;amp;issuer._&amp;amp;run_dt..txt"
				dbms=dlm
				replace ;
				delimiter="|" ;
			run ;
			
		%end ;
	
	%end ;

%mend ;

DATA _null_ ;
  SET fl_nms ;
	call execute('%impt('||fl_nm||')');
RUN ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;LOG&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: PROCEDURE PRINTTO used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
      

2    %let run_dt = %sysfunc(today(), yymmddn.) ;
3    %let issuer_ids = 80473/25768 ; /*This is used for the status file names.*/
4    
5    libname wrk "/sasuser/mclevx1/workspace";
NOTE: Libref WRK was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: /sasuser/mclevx1/workspace
6    libname kb "/sasuser/bailkx4/wrk/edge/dat/med" ;
NOTE: Libref KB was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: /sasuser/bailkx4/wrk/edge/dat/med
7    
8    libname aca_enr  "/au/test/aca/dat/enr";
NOTE: Libref ACA_ENR was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: /au/test/aca/dat/enr
9    libname ras_repc "/au/test/ras_repc/dat";
NOTE: Libref RAS_REPC was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: /au/test/ras_repc/dat
10   
11   /*EDGE SUPP IMPORT*/
12   %let edg_sup = /sasuser/bailkx4/wrk/edge/dat/sup/ ;
13   libname edg_sup "&amp;amp;edg_sup." ;
SYMBOLGEN:  Macro variable EDG_SUP resolves to /sasuser/bailkx4/wrk/edge/dat/sup/
NOTE: Libref EDG_SUP was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: /sasuser/bailkx4/wrk/edge/dat/sup
14   
15   %let edg_med = /au/test/edge/dat/med/ ;
16   libname edg_med "&amp;amp;edg_med." ;
SYMBOLGEN:  Macro variable EDG_MED resolves to /au/test/edge/dat/med/
NOTE: Libref EDG_MED was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: /au/test/edge/dat/med
17   
18   /* Filenames to import */
19   DATA fl_nms ;
20   	input fl_nm $30. ;
21   	datalines ;

NOTE: The data set WORK.FL_NMS has 4 observations and 1 variables.
NOTE: Compressing data set WORK.FL_NMS increased size by 100.00 percent. 
      Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

26   ;
27   RUN ;
28   %macro impt(nm) ;
29   	
30   	DATA &amp;amp;nm. ;
31   	infile "&amp;amp;edg_sup.&amp;amp;nm..txt" delimiter = '09'x MISSOVER DSD lrecl=32767 firstobs = 2 ;
32   		informat csr_nbr $9. ;
33   		informat clm_nbr $13. ;
34   		informat dos anydtdte10. ;
35   		informat dx_code $10. ;
36   		informat status $1. ;
37   		format dos mmddyy10. ;
38   		input csr_nbr
39   			clm_nbr
40   			dos
41   			dx_code
42   			status ;
43   		tmp = compress(tranwrd(dx_code,".","")) ; /*Remove periods from dx codes*/
44   		drop dx_code ;
45   		rename tmp = dx_code ;
46   	RUN ;
47   	
48   	/* Determine the year range */
49   	PROC SQL noprint ;
50   		select max(min(yrs),2016), max(yrs) /*2014 and 2015 claims will need to be manually reviewed*/
51   		into :min_yr , :max_yr
52   		from
53   			(
54   				select distinct year(dos) as yrs
55   				from &amp;amp;nm.
56   				where not(missing(dos))
57   			) ;
58   	QUIT ;
59   	
60   	%do i = &amp;amp;&amp;amp;min_yr. %to &amp;amp;&amp;amp;max_yr. ;
61   
62   		%let _len_j = %eval(%sysfunc(countc(&amp;amp;issuer_ids.,/)) + 1) ;
63   
64   		%do jj = 1 %to &amp;amp;_len_j. ;
65   			
66   			%let issuer = %scan(&amp;amp;issuer_ids.,&amp;amp;jj.) ;
67   
68   			proc sql ;
69   			create table tmp_&amp;amp;nm._&amp;amp;i._&amp;amp;issuer. as
70   			select distinct a.*
71   			from &amp;amp;nm. a
72   			inner join kb.edg_med_&amp;amp;i._&amp;amp;issuer. b /*submitted edge data*/
73   				on a.clm_nbr = b.edg_claim_id
74   			where b.au_lst_adj = 'Y' and year(dos) = &amp;amp;i.
75   			order by a.csr_nbr
76   				,a.clm_nbr
77   				,a.dos
78   				,a.dx_code ;
79   			quit ;
80   			
81   			/*Prepare data to submit to RADA for FIU*/
82   			DATA edg_sup.&amp;amp;nm._&amp;amp;i._&amp;amp;issuer. (keep = csr_nbr clm_nbr dos dx_code status)
83   				edg_sup.&amp;amp;nm._fiu_&amp;amp;i._&amp;amp;issuer. (keep = region_code mrn dos clm_nbr purpose diagnosis_code rename = (clm_nbr = edg_claim_id) );
84   			  SET tmp_&amp;amp;nm._&amp;amp;i._&amp;amp;issuer. ;
85   				
86   				region_code = 'WA' ;
87   				
88   				mrn = input(csr_nbr,9.) ;
89   				
90   				format purpose $5. ;
91   				if status = "A" then do ;
92   					purpose = "ADD" ;
93   				end ;
94   				else purpose = "DELDX" ;
95   
96   				diagnosis_code = dx_code ;
97   				
98   			RUN ;
99   
100  			/*Export FIU data file*/
101  			proc export data = edg_sup.&amp;amp;nm._&amp;amp;i._fiu_&amp;amp;issuer.
102  			  outfile = "&amp;amp;edg_sup.edge_&amp;amp;nm._&amp;amp;i._fiu_&amp;amp;issuer._&amp;amp;run_dt..txt"
103  				dbms=dlm
104  				replace ;
105  				delimiter="|" ;
106  			run ;
107  			
108  		%end ;
109  	
110  	%end ;
111  
112  %mend ;
113  
114  DATA _null_ ;
115    SET fl_nms ;
116  	call execute('%impt('||fl_nm||')');
117  RUN ;

NOTE: The macro IMPT is executing from memory.
      44 instructions 2432 bytes.
SYMBOLGEN:  Macro variable NM resolves to supp_thrombo
MPRINT(IMPT):   DATA supp_thrombo ;
SYMBOLGEN:  Macro variable EDG_SUP resolves to /sasuser/bailkx4/wrk/edge/dat/sup/
SYMBOLGEN:  Macro variable NM resolves to supp_thrombo
MPRINT(IMPT):   infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_thrombo.txt" delimiter = '09'x MISSOVER DSD lrecl=32767 firstobs = 2 ;
MPRINT(IMPT):   informat csr_nbr $9. ;
MPRINT(IMPT):   informat clm_nbr $13. ;
MPRINT(IMPT):   informat dos anydtdte10. ;
MPRINT(IMPT):   informat dx_code $10. ;
MPRINT(IMPT):   informat status $1. ;
MPRINT(IMPT):   format dos mmddyy10. ;
MPRINT(IMPT):   input csr_nbr clm_nbr dos dx_code status ;
MPRINT(IMPT):   tmp = compress(tranwrd(dx_code,".","")) ;
MPRINT(IMPT):   drop dx_code ;
MPRINT(IMPT):   rename tmp = dx_code ;
MPRINT(IMPT):   RUN ;
MPRINT(IMPT):   PROC SQL noprint ;
SYMBOLGEN:  Macro variable NM resolves to supp_thrombo
MPRINT(IMPT):   select max(min(yrs),2016), max(yrs) into :min_yr , :max_yr from ( select distinct year(dos) as yrs from supp_thrombo where not(missing(dos)) ) ;
MPRINT(IMPT):   QUIT ;
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
WARNING: Apparent symbolic reference MIN_YR not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &amp;amp;&amp;amp;min_yr. 
ERROR: The %FROM value of the %DO I loop is invalid.
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
WARNING: Apparent symbolic reference MAX_YR not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &amp;amp;&amp;amp;max_yr. 
ERROR: The %TO value of the %DO I loop is invalid.
ERROR: The macro IMPT will stop executing.
NOTE: The macro IMPT is executing from memory.
      44 instructions 2432 bytes.
SYMBOLGEN:  Macro variable NM resolves to supp_mdaudit
MPRINT(IMPT):   DATA supp_mdaudit ;
SYMBOLGEN:  Macro variable EDG_SUP resolves to /sasuser/bailkx4/wrk/edge/dat/sup/
SYMBOLGEN:  Macro variable NM resolves to supp_mdaudit
MPRINT(IMPT):   infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_mdaudit.txt" delimiter = '09'x MISSOVER DSD lrecl=32767 firstobs = 2 ;
MPRINT(IMPT):   informat csr_nbr $9. ;
MPRINT(IMPT):   informat clm_nbr $13. ;
MPRINT(IMPT):   informat dos anydtdte10. ;
MPRINT(IMPT):   informat dx_code $10. ;
MPRINT(IMPT):   informat status $1. ;
MPRINT(IMPT):   format dos mmddyy10. ;
MPRINT(IMPT):   input csr_nbr clm_nbr dos dx_code status ;
MPRINT(IMPT):   tmp = compress(tranwrd(dx_code,".","")) ;
MPRINT(IMPT):   drop dx_code ;
MPRINT(IMPT):   rename tmp = dx_code ;
MPRINT(IMPT):   RUN ;
MPRINT(IMPT):   PROC SQL noprint ;
SYMBOLGEN:  Macro variable NM resolves to supp_mdaudit
MPRINT(IMPT):   select max(min(yrs),2016), max(yrs) into :min_yr , :max_yr from ( select distinct year(dos) as yrs from supp_mdaudit where not(missing(dos)) ) ;
MPRINT(IMPT):   QUIT ;
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
WARNING: Apparent symbolic reference MIN_YR not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &amp;amp;&amp;amp;min_yr. 
ERROR: The %FROM value of the %DO I loop is invalid.
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
WARNING: Apparent symbolic reference MAX_YR not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &amp;amp;&amp;amp;max_yr. 
ERROR: The %TO value of the %DO I loop is invalid.
ERROR: The macro IMPT will stop executing.
NOTE: The macro IMPT is executing from memory.
      44 instructions 2432 bytes.
SYMBOLGEN:  Macro variable NM resolves to supp_immuno
MPRINT(IMPT):   DATA supp_immuno ;
SYMBOLGEN:  Macro variable EDG_SUP resolves to /sasuser/bailkx4/wrk/edge/dat/sup/
SYMBOLGEN:  Macro variable NM resolves to supp_immuno
MPRINT(IMPT):   infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_immuno.txt" delimiter = '09'x MISSOVER DSD lrecl=32767 firstobs = 2 ;
MPRINT(IMPT):   informat csr_nbr $9. ;
MPRINT(IMPT):   informat clm_nbr $13. ;
MPRINT(IMPT):   informat dos anydtdte10. ;
MPRINT(IMPT):   informat dx_code $10. ;
MPRINT(IMPT):   informat status $1. ;
MPRINT(IMPT):   format dos mmddyy10. ;
MPRINT(IMPT):   input csr_nbr clm_nbr dos dx_code status ;
MPRINT(IMPT):   tmp = compress(tranwrd(dx_code,".","")) ;
MPRINT(IMPT):   drop dx_code ;
MPRINT(IMPT):   rename tmp = dx_code ;
MPRINT(IMPT):   RUN ;
MPRINT(IMPT):   PROC SQL noprint ;
SYMBOLGEN:  Macro variable NM resolves to supp_immuno
MPRINT(IMPT):   select max(min(yrs),2016), max(yrs) into :min_yr , :max_yr from ( select distinct year(dos) as yrs from supp_immuno where not(missing(dos)) ) ;
MPRINT(IMPT):   QUIT ;
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
WARNING: Apparent symbolic reference MIN_YR not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &amp;amp;&amp;amp;min_yr. 
ERROR: The %FROM value of the %DO I loop is invalid.
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
WARNING: Apparent symbolic reference MAX_YR not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &amp;amp;&amp;amp;max_yr. 
ERROR: The %TO value of the %DO I loop is invalid.
ERROR: The macro IMPT will stop executing.
NOTE: The macro IMPT is executing from memory.
      44 instructions 2432 bytes.
SYMBOLGEN:  Macro variable NM resolves to supp_deact_imo
MPRINT(IMPT):   DATA supp_deact_imo ;
SYMBOLGEN:  Macro variable EDG_SUP resolves to /sasuser/bailkx4/wrk/edge/dat/sup/
SYMBOLGEN:  Macro variable NM resolves to supp_deact_imo
MPRINT(IMPT):   infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_deact_imo.txt" delimiter = '09'x MISSOVER DSD lrecl=32767 firstobs = 2 ;
MPRINT(IMPT):   informat csr_nbr $9. ;
MPRINT(IMPT):   informat clm_nbr $13. ;
MPRINT(IMPT):   informat dos anydtdte10. ;
MPRINT(IMPT):   informat dx_code $10. ;
MPRINT(IMPT):   informat status $1. ;
MPRINT(IMPT):   format dos mmddyy10. ;
MPRINT(IMPT):   input csr_nbr clm_nbr dos dx_code status ;
MPRINT(IMPT):   tmp = compress(tranwrd(dx_code,".","")) ;
MPRINT(IMPT):   drop dx_code ;
MPRINT(IMPT):   rename tmp = dx_code ;
MPRINT(IMPT):   RUN ;
MPRINT(IMPT):   PROC SQL noprint ;
SYMBOLGEN:  Macro variable NM resolves to supp_deact_imo
MPRINT(IMPT):   select max(min(yrs),2016), max(yrs) into :min_yr , :max_yr from ( select distinct year(dos) as yrs from supp_deact_imo where not(missing(dos)) ) ;
MPRINT(IMPT):   QUIT ;
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
WARNING: Apparent symbolic reference MIN_YR not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &amp;amp;&amp;amp;min_yr. 
ERROR: The %FROM value of the %DO I loop is invalid.
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
WARNING: Apparent symbolic reference MAX_YR not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &amp;amp;&amp;amp;max_yr. 
ERROR: The %TO value of the %DO I loop is invalid.
ERROR: The macro IMPT will stop executing.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 4 observations read from the data set WORK.FL_NMS.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
      

NOTE: CALL EXECUTE generated line.
1   + DATA supp_thrombo ;  infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_thrombo.txt" delimiter = '09'x MISSOVER DSD lrecl=32767 firstobs = 2 ;   informat csr_nbr $9. 
;   informat clm_nbr $13. ;   informat dos anydtdte10. ;   informat dx_code $10. ;
2   + informat status $1. ;   format dos mmddyy10. ;   input csr_nbr    clm_nbr    dos    dx_code    status ;   tmp = compress(tranwrd(dx_code,".","")) ;    drop 
dx_code ;   rename tmp = dx_code ;  RUN ;

NOTE: The infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_thrombo.txt" is:
      Filename=/sasuser/bailkx4/wrk/edge/dat/sup/supp_thrombo.txt,
      Owner Name=bailkx4,Group Name=sasuser,
      Access Permission=-rw-r-----,
      Last Modified=14Apr2021:17:29:04,
      File Size (bytes)=17740

NOTE: 421 records were read from the infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_thrombo.txt".
      The minimum record length was 39.
      The maximum record length was 42.
NOTE: The data set WORK.SUPP_THROMBO has 421 observations and 5 variables.
NOTE: Compressing data set WORK.SUPP_THROMBO increased size by 100.00 percent. 
      Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds
      
2   +
            PROC SQL noprint ;   select max(min(yrs),2016), max

3   +(yrs)    into :min_yr , :max_yr   from    (     select distinct year(dos) as yrs     from supp_thrombo     where not(missing(dos))    ) ;
3   +                                                                                                                                           QUIT ;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds
      

4   + DATA supp_mdaudit ;  infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_mdaudit.txt" delimiter = '09'x MISSOVER DSD lrecl=32767 firstobs = 2 ;   informat csr_nbr $9. 
;   informat clm_nbr $13. ;   informat dos anydtdte10. ;   informat dx_code $10. ;
5   + informat status $1. ;   format dos mmddyy10. ;   input csr_nbr    clm_nbr    dos    dx_code    status ;   tmp = compress(tranwrd(dx_code,".","")) ;    drop 
dx_code ;   rename tmp = dx_code ;  RUN ;

NOTE: The infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_mdaudit.txt" is:
      Filename=/sasuser/bailkx4/wrk/edge/dat/sup/supp_mdaudit.txt,
      Owner Name=bailkx4,Group Name=sasuser,
      Access Permission=-rw-------,
      Last Modified=14Apr2021:12:13:06,
      File Size (bytes)=1727

NOTE: 42 records were read from the infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_mdaudit.txt".
      The minimum record length was 39.
      The maximum record length was 40.
NOTE: The data set WORK.SUPP_MDAUDIT has 42 observations and 5 variables.
NOTE: Compressing data set WORK.SUPP_MDAUDIT increased size by 100.00 percent. 
      Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      
5   +
            PROC SQL noprint ;   select max(min(yrs),2016), max

6   +(yrs)    into :min_yr , :max_yr   from    (     select distinct year(dos) as yrs     from supp_mdaudit     where not(missing(dos))    ) ;
6   +                                                                                                                                           QUIT ;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds
      

7   + DATA supp_immuno ;  infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_immuno.txt" delimiter = '09'x MISSOVER DSD lrecl=32767 firstobs = 2 ;   informat csr_nbr $9. ; 
  informat clm_nbr $13. ;   informat dos anydtdte10. ;   informat dx_code $10. ;   informat
8   + status $1. ;   format dos mmddyy10. ;   input csr_nbr    clm_nbr    dos    dx_code    status ;   tmp = compress(tranwrd(dx_code,".","")) ;    drop dx_code ;   
rename tmp = dx_code ;  RUN ;

NOTE: The infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_immuno.txt" is:
      Filename=/sasuser/bailkx4/wrk/edge/dat/sup/supp_immuno.txt,
      Owner Name=bailkx4,Group Name=sasuser,
      Access Permission=-rw-r-----,
      Last Modified=14Apr2021:12:22:30,
      File Size (bytes)=18009

NOTE: 428 records were read from the infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_immuno.txt".
      The minimum record length was 39.
      The maximum record length was 41.
NOTE: The data set WORK.SUPP_IMMUNO has 428 observations and 5 variables.
NOTE: Compressing data set WORK.SUPP_IMMUNO increased size by 100.00 percent. 
      Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.02 seconds
      
8   +
            PROC SQL noprint ;   select max(min(yrs),2016), max(yrs)

9   + into :min_yr , :max_yr   from    (     select distinct year(dos) as yrs     from supp_immuno     where not(missing(dos))    ) ;
9   +                                                                                                                                  QUIT ;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.02 seconds
      cpu time            0.02 seconds
      

10  + DATA supp_deact_imo ;  infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_deact_imo.txt" delimiter = '09'x MISSOVER DSD lrecl=32767 firstobs = 2 ;   informat csr_nbr 
$9. ;   informat clm_nbr $13. ;   informat dos anydtdte10. ;   informat dx_code $10. ;
11  + informat status $1. ;   format dos mmddyy10. ;   input csr_nbr    clm_nbr    dos    dx_code    status ;   tmp = compress(tranwrd(dx_code,".","")) ;    drop 
dx_code ;   rename tmp = dx_code ;  RUN ;

NOTE: The infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_deact_imo.txt" is:
      Filename=/sasuser/bailkx4/wrk/edge/dat/sup/supp_deact_imo.txt,
      Owner Name=bailkx4,Group Name=sasuser,
      Access Permission=-rw-r-----,
      Last Modified=14Apr2021:13:56:12,
      File Size (bytes)=463

NOTE: 10 records were read from the infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_deact_imo.txt".
      The minimum record length was 40.
      The maximum record length was 42.
NOTE: The data set WORK.SUPP_DEACT_IMO has 10 observations and 5 variables.
NOTE: Compressing data set WORK.SUPP_DEACT_IMO increased size by 100.00 percent. 
      Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      
11  +
            PROC SQL noprint ;   select max(min(yrs),2016), max

12  +(yrs)    into :min_yr , :max_yr   from    (     select distinct year(dos) as yrs     from supp_deact_imo     where not(missing(dos))    ) ;
12  +                                                                                                                                             QUIT ;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.01 seconds
      cpu time            0.02 seconds
      &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Apr 2021 17:53:52 GMT</pubDate>
    <dc:creator>kb011235</dc:creator>
    <dc:date>2021-04-20T17:53:52Z</dc:date>
    <item>
      <title>macro variables in macro not resolving</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variables-in-macro-not-resolving/m-p/735697#M229178</link>
      <description>&lt;P&gt;Hi, the problem my code is having is that the min_yr and max_yr variables within the macro aren't resolving. Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;CODE&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let run_dt = %sysfunc(today(), yymmddn.) ;
%let issuer_ids = 80473/25768 ; /*This is used for the status file names.*/

libname wrk "/sasuser/mclevx1/workspace";
libname kb "/sasuser/bailkx4/wrk/edge/dat/med" ;

libname aca_enr  "/au/test/aca/dat/enr";
libname ras_repc "/au/test/ras_repc/dat";

/*EDGE SUPP IMPORT*/
%let edg_sup = /sasuser/bailkx4/wrk/edge/dat/sup/ ;
libname edg_sup "&amp;amp;edg_sup." ;

%let edg_med = /au/test/edge/dat/med/ ;
libname edg_med "&amp;amp;edg_med." ;

/* Filenames to import */
DATA fl_nms ;
	input fl_nm $30. ;
	datalines ;
supp_thrombo
supp_mdaudit
supp_immuno
supp_deact_imo
;
RUN ;

%macro impt(nm) ;
	
	DATA &amp;amp;nm. ; 
	infile "&amp;amp;edg_sup.&amp;amp;nm..txt" delimiter = '09'x MISSOVER DSD lrecl=32767 firstobs = 2 ;
		informat csr_nbr $9. ;
		informat clm_nbr $13. ;
		informat dos anydtdte10. ;
		informat dx_code $10. ;
		informat status $1. ;
		format dos mmddyy10. ;
		input csr_nbr
			clm_nbr
			dos
			dx_code
			status ; 
		tmp = compress(tranwrd(dx_code,".","")) ; /*Remove periods from dx codes*/
		drop dx_code ;
		rename tmp = dx_code ;
	RUN ;
	
	/* Determine the year range */
	PROC SQL noprint ;
		select max(min(yrs),2016), max(yrs) /*2014 and 2015 claims will need to be manually reviewed*/
		into :&lt;FONT color="#FF0000"&gt;min_yr &lt;/FONT&gt;, :&lt;FONT color="#FF0000"&gt;max_yr&lt;/FONT&gt; 
		from 
			(
				select distinct year(dos) as yrs
				from &amp;amp;nm.
				where not(missing(dos))
			) ;
	QUIT ;
	
	%do i = &amp;amp;&amp;amp;min_yr. %to &amp;amp;&amp;amp;max_yr. ;

		%let _len_j = %eval(%sysfunc(countc(&amp;amp;issuer_ids.,/)) + 1) ;

		%do jj = 1 %to &amp;amp;_len_j. ;
			
			%let issuer = %scan(&amp;amp;issuer_ids.,&amp;amp;jj.) ;

			proc sql ;
			create table tmp_&amp;amp;nm._&amp;amp;i._&amp;amp;issuer. as 
			select distinct a.*
			from &amp;amp;nm. a 
			inner join kb.edg_med_&amp;amp;i._&amp;amp;issuer. b /*submitted edge data*/
				on a.clm_nbr = b.edg_claim_id
			where b.au_lst_adj = 'Y' and year(dos) = &amp;amp;i.
			order by a.csr_nbr
				,a.clm_nbr
				,a.dos
				,a.dx_code ;
			quit ;
			
			/*Prepare data to submit to RADA for FIU*/
			DATA edg_sup.&amp;amp;nm._&amp;amp;i._&amp;amp;issuer. (keep = csr_nbr clm_nbr dos dx_code status)
				edg_sup.&amp;amp;nm._fiu_&amp;amp;i._&amp;amp;issuer. (keep = region_code mrn dos clm_nbr purpose diagnosis_code rename = (clm_nbr = edg_claim_id) );
			  SET tmp_&amp;amp;nm._&amp;amp;i._&amp;amp;issuer. ;
				
				region_code = 'WA' ;
				
				mrn = input(csr_nbr,9.) ; 
				
				format purpose $5. ;
				if status = "A" then do ;
					purpose = "ADD" ;
				end ;
				else purpose = "DELDX" ;

				diagnosis_code = dx_code ;
				
			RUN ;

			/*Export FIU data file*/
			proc export data = edg_sup.&amp;amp;nm._&amp;amp;i._fiu_&amp;amp;issuer.
			  outfile = "&amp;amp;edg_sup.edge_&amp;amp;nm._&amp;amp;i._fiu_&amp;amp;issuer._&amp;amp;run_dt..txt"
				dbms=dlm
				replace ;
				delimiter="|" ;
			run ;
			
		%end ;
	
	%end ;

%mend ;

DATA _null_ ;
  SET fl_nms ;
	call execute('%impt('||fl_nm||')');
RUN ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;LOG&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: PROCEDURE PRINTTO used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
      

2    %let run_dt = %sysfunc(today(), yymmddn.) ;
3    %let issuer_ids = 80473/25768 ; /*This is used for the status file names.*/
4    
5    libname wrk "/sasuser/mclevx1/workspace";
NOTE: Libref WRK was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: /sasuser/mclevx1/workspace
6    libname kb "/sasuser/bailkx4/wrk/edge/dat/med" ;
NOTE: Libref KB was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: /sasuser/bailkx4/wrk/edge/dat/med
7    
8    libname aca_enr  "/au/test/aca/dat/enr";
NOTE: Libref ACA_ENR was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: /au/test/aca/dat/enr
9    libname ras_repc "/au/test/ras_repc/dat";
NOTE: Libref RAS_REPC was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: /au/test/ras_repc/dat
10   
11   /*EDGE SUPP IMPORT*/
12   %let edg_sup = /sasuser/bailkx4/wrk/edge/dat/sup/ ;
13   libname edg_sup "&amp;amp;edg_sup." ;
SYMBOLGEN:  Macro variable EDG_SUP resolves to /sasuser/bailkx4/wrk/edge/dat/sup/
NOTE: Libref EDG_SUP was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: /sasuser/bailkx4/wrk/edge/dat/sup
14   
15   %let edg_med = /au/test/edge/dat/med/ ;
16   libname edg_med "&amp;amp;edg_med." ;
SYMBOLGEN:  Macro variable EDG_MED resolves to /au/test/edge/dat/med/
NOTE: Libref EDG_MED was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: /au/test/edge/dat/med
17   
18   /* Filenames to import */
19   DATA fl_nms ;
20   	input fl_nm $30. ;
21   	datalines ;

NOTE: The data set WORK.FL_NMS has 4 observations and 1 variables.
NOTE: Compressing data set WORK.FL_NMS increased size by 100.00 percent. 
      Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

26   ;
27   RUN ;
28   %macro impt(nm) ;
29   	
30   	DATA &amp;amp;nm. ;
31   	infile "&amp;amp;edg_sup.&amp;amp;nm..txt" delimiter = '09'x MISSOVER DSD lrecl=32767 firstobs = 2 ;
32   		informat csr_nbr $9. ;
33   		informat clm_nbr $13. ;
34   		informat dos anydtdte10. ;
35   		informat dx_code $10. ;
36   		informat status $1. ;
37   		format dos mmddyy10. ;
38   		input csr_nbr
39   			clm_nbr
40   			dos
41   			dx_code
42   			status ;
43   		tmp = compress(tranwrd(dx_code,".","")) ; /*Remove periods from dx codes*/
44   		drop dx_code ;
45   		rename tmp = dx_code ;
46   	RUN ;
47   	
48   	/* Determine the year range */
49   	PROC SQL noprint ;
50   		select max(min(yrs),2016), max(yrs) /*2014 and 2015 claims will need to be manually reviewed*/
51   		into :min_yr , :max_yr
52   		from
53   			(
54   				select distinct year(dos) as yrs
55   				from &amp;amp;nm.
56   				where not(missing(dos))
57   			) ;
58   	QUIT ;
59   	
60   	%do i = &amp;amp;&amp;amp;min_yr. %to &amp;amp;&amp;amp;max_yr. ;
61   
62   		%let _len_j = %eval(%sysfunc(countc(&amp;amp;issuer_ids.,/)) + 1) ;
63   
64   		%do jj = 1 %to &amp;amp;_len_j. ;
65   			
66   			%let issuer = %scan(&amp;amp;issuer_ids.,&amp;amp;jj.) ;
67   
68   			proc sql ;
69   			create table tmp_&amp;amp;nm._&amp;amp;i._&amp;amp;issuer. as
70   			select distinct a.*
71   			from &amp;amp;nm. a
72   			inner join kb.edg_med_&amp;amp;i._&amp;amp;issuer. b /*submitted edge data*/
73   				on a.clm_nbr = b.edg_claim_id
74   			where b.au_lst_adj = 'Y' and year(dos) = &amp;amp;i.
75   			order by a.csr_nbr
76   				,a.clm_nbr
77   				,a.dos
78   				,a.dx_code ;
79   			quit ;
80   			
81   			/*Prepare data to submit to RADA for FIU*/
82   			DATA edg_sup.&amp;amp;nm._&amp;amp;i._&amp;amp;issuer. (keep = csr_nbr clm_nbr dos dx_code status)
83   				edg_sup.&amp;amp;nm._fiu_&amp;amp;i._&amp;amp;issuer. (keep = region_code mrn dos clm_nbr purpose diagnosis_code rename = (clm_nbr = edg_claim_id) );
84   			  SET tmp_&amp;amp;nm._&amp;amp;i._&amp;amp;issuer. ;
85   				
86   				region_code = 'WA' ;
87   				
88   				mrn = input(csr_nbr,9.) ;
89   				
90   				format purpose $5. ;
91   				if status = "A" then do ;
92   					purpose = "ADD" ;
93   				end ;
94   				else purpose = "DELDX" ;
95   
96   				diagnosis_code = dx_code ;
97   				
98   			RUN ;
99   
100  			/*Export FIU data file*/
101  			proc export data = edg_sup.&amp;amp;nm._&amp;amp;i._fiu_&amp;amp;issuer.
102  			  outfile = "&amp;amp;edg_sup.edge_&amp;amp;nm._&amp;amp;i._fiu_&amp;amp;issuer._&amp;amp;run_dt..txt"
103  				dbms=dlm
104  				replace ;
105  				delimiter="|" ;
106  			run ;
107  			
108  		%end ;
109  	
110  	%end ;
111  
112  %mend ;
113  
114  DATA _null_ ;
115    SET fl_nms ;
116  	call execute('%impt('||fl_nm||')');
117  RUN ;

NOTE: The macro IMPT is executing from memory.
      44 instructions 2432 bytes.
SYMBOLGEN:  Macro variable NM resolves to supp_thrombo
MPRINT(IMPT):   DATA supp_thrombo ;
SYMBOLGEN:  Macro variable EDG_SUP resolves to /sasuser/bailkx4/wrk/edge/dat/sup/
SYMBOLGEN:  Macro variable NM resolves to supp_thrombo
MPRINT(IMPT):   infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_thrombo.txt" delimiter = '09'x MISSOVER DSD lrecl=32767 firstobs = 2 ;
MPRINT(IMPT):   informat csr_nbr $9. ;
MPRINT(IMPT):   informat clm_nbr $13. ;
MPRINT(IMPT):   informat dos anydtdte10. ;
MPRINT(IMPT):   informat dx_code $10. ;
MPRINT(IMPT):   informat status $1. ;
MPRINT(IMPT):   format dos mmddyy10. ;
MPRINT(IMPT):   input csr_nbr clm_nbr dos dx_code status ;
MPRINT(IMPT):   tmp = compress(tranwrd(dx_code,".","")) ;
MPRINT(IMPT):   drop dx_code ;
MPRINT(IMPT):   rename tmp = dx_code ;
MPRINT(IMPT):   RUN ;
MPRINT(IMPT):   PROC SQL noprint ;
SYMBOLGEN:  Macro variable NM resolves to supp_thrombo
MPRINT(IMPT):   select max(min(yrs),2016), max(yrs) into :min_yr , :max_yr from ( select distinct year(dos) as yrs from supp_thrombo where not(missing(dos)) ) ;
MPRINT(IMPT):   QUIT ;
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
WARNING: Apparent symbolic reference MIN_YR not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &amp;amp;&amp;amp;min_yr. 
ERROR: The %FROM value of the %DO I loop is invalid.
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
WARNING: Apparent symbolic reference MAX_YR not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &amp;amp;&amp;amp;max_yr. 
ERROR: The %TO value of the %DO I loop is invalid.
ERROR: The macro IMPT will stop executing.
NOTE: The macro IMPT is executing from memory.
      44 instructions 2432 bytes.
SYMBOLGEN:  Macro variable NM resolves to supp_mdaudit
MPRINT(IMPT):   DATA supp_mdaudit ;
SYMBOLGEN:  Macro variable EDG_SUP resolves to /sasuser/bailkx4/wrk/edge/dat/sup/
SYMBOLGEN:  Macro variable NM resolves to supp_mdaudit
MPRINT(IMPT):   infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_mdaudit.txt" delimiter = '09'x MISSOVER DSD lrecl=32767 firstobs = 2 ;
MPRINT(IMPT):   informat csr_nbr $9. ;
MPRINT(IMPT):   informat clm_nbr $13. ;
MPRINT(IMPT):   informat dos anydtdte10. ;
MPRINT(IMPT):   informat dx_code $10. ;
MPRINT(IMPT):   informat status $1. ;
MPRINT(IMPT):   format dos mmddyy10. ;
MPRINT(IMPT):   input csr_nbr clm_nbr dos dx_code status ;
MPRINT(IMPT):   tmp = compress(tranwrd(dx_code,".","")) ;
MPRINT(IMPT):   drop dx_code ;
MPRINT(IMPT):   rename tmp = dx_code ;
MPRINT(IMPT):   RUN ;
MPRINT(IMPT):   PROC SQL noprint ;
SYMBOLGEN:  Macro variable NM resolves to supp_mdaudit
MPRINT(IMPT):   select max(min(yrs),2016), max(yrs) into :min_yr , :max_yr from ( select distinct year(dos) as yrs from supp_mdaudit where not(missing(dos)) ) ;
MPRINT(IMPT):   QUIT ;
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
WARNING: Apparent symbolic reference MIN_YR not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &amp;amp;&amp;amp;min_yr. 
ERROR: The %FROM value of the %DO I loop is invalid.
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
WARNING: Apparent symbolic reference MAX_YR not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &amp;amp;&amp;amp;max_yr. 
ERROR: The %TO value of the %DO I loop is invalid.
ERROR: The macro IMPT will stop executing.
NOTE: The macro IMPT is executing from memory.
      44 instructions 2432 bytes.
SYMBOLGEN:  Macro variable NM resolves to supp_immuno
MPRINT(IMPT):   DATA supp_immuno ;
SYMBOLGEN:  Macro variable EDG_SUP resolves to /sasuser/bailkx4/wrk/edge/dat/sup/
SYMBOLGEN:  Macro variable NM resolves to supp_immuno
MPRINT(IMPT):   infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_immuno.txt" delimiter = '09'x MISSOVER DSD lrecl=32767 firstobs = 2 ;
MPRINT(IMPT):   informat csr_nbr $9. ;
MPRINT(IMPT):   informat clm_nbr $13. ;
MPRINT(IMPT):   informat dos anydtdte10. ;
MPRINT(IMPT):   informat dx_code $10. ;
MPRINT(IMPT):   informat status $1. ;
MPRINT(IMPT):   format dos mmddyy10. ;
MPRINT(IMPT):   input csr_nbr clm_nbr dos dx_code status ;
MPRINT(IMPT):   tmp = compress(tranwrd(dx_code,".","")) ;
MPRINT(IMPT):   drop dx_code ;
MPRINT(IMPT):   rename tmp = dx_code ;
MPRINT(IMPT):   RUN ;
MPRINT(IMPT):   PROC SQL noprint ;
SYMBOLGEN:  Macro variable NM resolves to supp_immuno
MPRINT(IMPT):   select max(min(yrs),2016), max(yrs) into :min_yr , :max_yr from ( select distinct year(dos) as yrs from supp_immuno where not(missing(dos)) ) ;
MPRINT(IMPT):   QUIT ;
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
WARNING: Apparent symbolic reference MIN_YR not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &amp;amp;&amp;amp;min_yr. 
ERROR: The %FROM value of the %DO I loop is invalid.
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
WARNING: Apparent symbolic reference MAX_YR not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &amp;amp;&amp;amp;max_yr. 
ERROR: The %TO value of the %DO I loop is invalid.
ERROR: The macro IMPT will stop executing.
NOTE: The macro IMPT is executing from memory.
      44 instructions 2432 bytes.
SYMBOLGEN:  Macro variable NM resolves to supp_deact_imo
MPRINT(IMPT):   DATA supp_deact_imo ;
SYMBOLGEN:  Macro variable EDG_SUP resolves to /sasuser/bailkx4/wrk/edge/dat/sup/
SYMBOLGEN:  Macro variable NM resolves to supp_deact_imo
MPRINT(IMPT):   infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_deact_imo.txt" delimiter = '09'x MISSOVER DSD lrecl=32767 firstobs = 2 ;
MPRINT(IMPT):   informat csr_nbr $9. ;
MPRINT(IMPT):   informat clm_nbr $13. ;
MPRINT(IMPT):   informat dos anydtdte10. ;
MPRINT(IMPT):   informat dx_code $10. ;
MPRINT(IMPT):   informat status $1. ;
MPRINT(IMPT):   format dos mmddyy10. ;
MPRINT(IMPT):   input csr_nbr clm_nbr dos dx_code status ;
MPRINT(IMPT):   tmp = compress(tranwrd(dx_code,".","")) ;
MPRINT(IMPT):   drop dx_code ;
MPRINT(IMPT):   rename tmp = dx_code ;
MPRINT(IMPT):   RUN ;
MPRINT(IMPT):   PROC SQL noprint ;
SYMBOLGEN:  Macro variable NM resolves to supp_deact_imo
MPRINT(IMPT):   select max(min(yrs),2016), max(yrs) into :min_yr , :max_yr from ( select distinct year(dos) as yrs from supp_deact_imo where not(missing(dos)) ) ;
MPRINT(IMPT):   QUIT ;
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
WARNING: Apparent symbolic reference MIN_YR not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &amp;amp;&amp;amp;min_yr. 
ERROR: The %FROM value of the %DO I loop is invalid.
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
WARNING: Apparent symbolic reference MAX_YR not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &amp;amp;&amp;amp;max_yr. 
ERROR: The %TO value of the %DO I loop is invalid.
ERROR: The macro IMPT will stop executing.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 4 observations read from the data set WORK.FL_NMS.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
      

NOTE: CALL EXECUTE generated line.
1   + DATA supp_thrombo ;  infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_thrombo.txt" delimiter = '09'x MISSOVER DSD lrecl=32767 firstobs = 2 ;   informat csr_nbr $9. 
;   informat clm_nbr $13. ;   informat dos anydtdte10. ;   informat dx_code $10. ;
2   + informat status $1. ;   format dos mmddyy10. ;   input csr_nbr    clm_nbr    dos    dx_code    status ;   tmp = compress(tranwrd(dx_code,".","")) ;    drop 
dx_code ;   rename tmp = dx_code ;  RUN ;

NOTE: The infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_thrombo.txt" is:
      Filename=/sasuser/bailkx4/wrk/edge/dat/sup/supp_thrombo.txt,
      Owner Name=bailkx4,Group Name=sasuser,
      Access Permission=-rw-r-----,
      Last Modified=14Apr2021:17:29:04,
      File Size (bytes)=17740

NOTE: 421 records were read from the infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_thrombo.txt".
      The minimum record length was 39.
      The maximum record length was 42.
NOTE: The data set WORK.SUPP_THROMBO has 421 observations and 5 variables.
NOTE: Compressing data set WORK.SUPP_THROMBO increased size by 100.00 percent. 
      Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds
      
2   +
            PROC SQL noprint ;   select max(min(yrs),2016), max

3   +(yrs)    into :min_yr , :max_yr   from    (     select distinct year(dos) as yrs     from supp_thrombo     where not(missing(dos))    ) ;
3   +                                                                                                                                           QUIT ;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds
      

4   + DATA supp_mdaudit ;  infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_mdaudit.txt" delimiter = '09'x MISSOVER DSD lrecl=32767 firstobs = 2 ;   informat csr_nbr $9. 
;   informat clm_nbr $13. ;   informat dos anydtdte10. ;   informat dx_code $10. ;
5   + informat status $1. ;   format dos mmddyy10. ;   input csr_nbr    clm_nbr    dos    dx_code    status ;   tmp = compress(tranwrd(dx_code,".","")) ;    drop 
dx_code ;   rename tmp = dx_code ;  RUN ;

NOTE: The infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_mdaudit.txt" is:
      Filename=/sasuser/bailkx4/wrk/edge/dat/sup/supp_mdaudit.txt,
      Owner Name=bailkx4,Group Name=sasuser,
      Access Permission=-rw-------,
      Last Modified=14Apr2021:12:13:06,
      File Size (bytes)=1727

NOTE: 42 records were read from the infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_mdaudit.txt".
      The minimum record length was 39.
      The maximum record length was 40.
NOTE: The data set WORK.SUPP_MDAUDIT has 42 observations and 5 variables.
NOTE: Compressing data set WORK.SUPP_MDAUDIT increased size by 100.00 percent. 
      Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      
5   +
            PROC SQL noprint ;   select max(min(yrs),2016), max

6   +(yrs)    into :min_yr , :max_yr   from    (     select distinct year(dos) as yrs     from supp_mdaudit     where not(missing(dos))    ) ;
6   +                                                                                                                                           QUIT ;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds
      

7   + DATA supp_immuno ;  infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_immuno.txt" delimiter = '09'x MISSOVER DSD lrecl=32767 firstobs = 2 ;   informat csr_nbr $9. ; 
  informat clm_nbr $13. ;   informat dos anydtdte10. ;   informat dx_code $10. ;   informat
8   + status $1. ;   format dos mmddyy10. ;   input csr_nbr    clm_nbr    dos    dx_code    status ;   tmp = compress(tranwrd(dx_code,".","")) ;    drop dx_code ;   
rename tmp = dx_code ;  RUN ;

NOTE: The infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_immuno.txt" is:
      Filename=/sasuser/bailkx4/wrk/edge/dat/sup/supp_immuno.txt,
      Owner Name=bailkx4,Group Name=sasuser,
      Access Permission=-rw-r-----,
      Last Modified=14Apr2021:12:22:30,
      File Size (bytes)=18009

NOTE: 428 records were read from the infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_immuno.txt".
      The minimum record length was 39.
      The maximum record length was 41.
NOTE: The data set WORK.SUPP_IMMUNO has 428 observations and 5 variables.
NOTE: Compressing data set WORK.SUPP_IMMUNO increased size by 100.00 percent. 
      Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.02 seconds
      
8   +
            PROC SQL noprint ;   select max(min(yrs),2016), max(yrs)

9   + into :min_yr , :max_yr   from    (     select distinct year(dos) as yrs     from supp_immuno     where not(missing(dos))    ) ;
9   +                                                                                                                                  QUIT ;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.02 seconds
      cpu time            0.02 seconds
      

10  + DATA supp_deact_imo ;  infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_deact_imo.txt" delimiter = '09'x MISSOVER DSD lrecl=32767 firstobs = 2 ;   informat csr_nbr 
$9. ;   informat clm_nbr $13. ;   informat dos anydtdte10. ;   informat dx_code $10. ;
11  + informat status $1. ;   format dos mmddyy10. ;   input csr_nbr    clm_nbr    dos    dx_code    status ;   tmp = compress(tranwrd(dx_code,".","")) ;    drop 
dx_code ;   rename tmp = dx_code ;  RUN ;

NOTE: The infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_deact_imo.txt" is:
      Filename=/sasuser/bailkx4/wrk/edge/dat/sup/supp_deact_imo.txt,
      Owner Name=bailkx4,Group Name=sasuser,
      Access Permission=-rw-r-----,
      Last Modified=14Apr2021:13:56:12,
      File Size (bytes)=463

NOTE: 10 records were read from the infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_deact_imo.txt".
      The minimum record length was 40.
      The maximum record length was 42.
NOTE: The data set WORK.SUPP_DEACT_IMO has 10 observations and 5 variables.
NOTE: Compressing data set WORK.SUPP_DEACT_IMO increased size by 100.00 percent. 
      Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      
11  +
            PROC SQL noprint ;   select max(min(yrs),2016), max

12  +(yrs)    into :min_yr , :max_yr   from    (     select distinct year(dos) as yrs     from supp_deact_imo     where not(missing(dos))    ) ;
12  +                                                                                                                                             QUIT ;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.01 seconds
      cpu time            0.02 seconds
      &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 17:53:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variables-in-macro-not-resolving/m-p/735697#M229178</guid>
      <dc:creator>kb011235</dc:creator>
      <dc:date>2021-04-20T17:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: macro variables in macro not resolving</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variables-in-macro-not-resolving/m-p/735711#M229182</link>
      <description>&lt;PRE&gt;SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
WARNING: Apparent symbolic reference MIN_YR not resolved.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &amp;amp;&amp;amp;min_yr. 
ERROR: The %FROM value of the %DO I loop is invalid.
&lt;/PRE&gt;
&lt;P&gt;It doesn't like &amp;amp;&amp;amp;MIN_YR. I don't know, as I haven't gone through your code in detail, why you need a &amp;amp;&amp;amp; instead of &amp;amp;. Why do you use a &amp;amp;&amp;amp;?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 18:10:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variables-in-macro-not-resolving/m-p/735711#M229182</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-20T18:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: macro variables in macro not resolving</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variables-in-macro-not-resolving/m-p/735735#M229191</link>
      <description>&lt;P&gt;CALL EXECUTE presents some tough timing issues.&amp;nbsp; It attempts to run all macro statements right away, but has to wait until the DATA step is over to execute the SAS language statements.&amp;nbsp; That throws off your logic, as the %do jj=1 %to .... executes before SQL creates your macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can fix the issue (delaying the execution of macro statements within the code called by CALL EXECUTE) with one change:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call execute('%nrstr(%impt('||fl_nm||'))');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Apr 2021 19:36:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variables-in-macro-not-resolving/m-p/735735#M229191</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-04-20T19:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: macro variables in macro not resolving</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variables-in-macro-not-resolving/m-p/735739#M229193</link>
      <description>&lt;P&gt;This line in your macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	%do i = &amp;amp;&amp;amp;min_yr. %to &amp;amp;&amp;amp;max_yr. ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is trying to reference macro variables created by the earlier PROC SQL code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select max(min(yrs),2016), max(yrs) into :min_yr , :max_yr 
...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But that code has not yet run because your data step is still running.&lt;/P&gt;
&lt;P&gt;So just use %NRSTR() to prevent the macro from running while the CALL EXECUTE() statement is running.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call execute(cats('%nrstr(%impt)(',fl_nm,')'));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In addition to fixing the timing issue it will also make your SAS log more readable.&amp;nbsp; Instead of this gibberish:&lt;/P&gt;
&lt;PRE&gt;NOTE: CALL EXECUTE generated line.
1   + DATA supp_thrombo ;  infile "/sasuser/bailkx4/wrk/edge/dat/sup/supp_thrombo.txt" delimiter = '09'x MISSOVER DSD lrecl=32767 firstobs = 2 ;   informat csr_nbr $9. 
;   informat clm_nbr $13. ;   informat dos anydtdte10. ;   informat dx_code $10. ;
2   + informat status $1. ;   format dos mmddyy10. ;   input csr_nbr    clm_nbr    dos    dx_code    status ;   tmp = compress(tranwrd(dx_code,".","")) ;    drop 
dx_code ;   rename tmp = dx_code ;  RUN ;&lt;/PRE&gt;
&lt;P&gt;You will see:&lt;/P&gt;
&lt;PRE&gt;NOTE: CALL EXECUTE generated line.
1   + %impt(supp_thrombo)&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Apr 2021 19:45:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variables-in-macro-not-resolving/m-p/735739#M229193</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-20T19:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: macro variables in macro not resolving</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variables-in-macro-not-resolving/m-p/735744#M229194</link>
      <description>&lt;P&gt;Thank you much. I was having a similar issue with another macro that was supposed to create a dataset if it didn't already exist (if not(exist(data)) then create data), except the dataset was created with each loop. In that project I was able to create the dataset only when _n_=1 since the exist function wasn't working as intended.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Apr 2021 20:03:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variables-in-macro-not-resolving/m-p/735744#M229194</guid>
      <dc:creator>kb011235</dc:creator>
      <dc:date>2021-04-20T20:03:35Z</dc:date>
    </item>
  </channel>
</rss>

