BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kb011235
Obsidian | Level 7

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.

CODE

%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 "&edg_sup." ;

%let edg_med = /au/test/edge/dat/med/ ;
libname edg_med "&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 &nm. ; 
	infile "&edg_sup.&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 :min_yr , :max_yr 
		from 
			(
				select distinct year(dos) as yrs
				from &nm.
				where not(missing(dos))
			) ;
	QUIT ;
	
	%do i = &&min_yr. %to &&max_yr. ;

		%let _len_j = %eval(%sysfunc(countc(&issuer_ids.,/)) + 1) ;

		%do jj = 1 %to &_len_j. ;
			
			%let issuer = %scan(&issuer_ids.,&jj.) ;

			proc sql ;
			create table tmp_&nm._&i._&issuer. as 
			select distinct a.*
			from &nm. a 
			inner join kb.edg_med_&i._&issuer. b /*submitted edge data*/
				on a.clm_nbr = b.edg_claim_id
			where b.au_lst_adj = 'Y' and year(dos) = &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.&nm._&i._&issuer. (keep = csr_nbr clm_nbr dos dx_code status)
				edg_sup.&nm._fiu_&i._&issuer. (keep = region_code mrn dos clm_nbr purpose diagnosis_code rename = (clm_nbr = edg_claim_id) );
			  SET tmp_&nm._&i._&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.&nm._&i._fiu_&issuer.
			  outfile = "&edg_sup.edge_&nm._&i._fiu_&issuer._&run_dt..txt"
				dbms=dlm
				replace ;
				delimiter="|" ;
			run ;
			
		%end ;
	
	%end ;

%mend ;

DATA _null_ ;
  SET fl_nms ;
	call execute('%impt('||fl_nm||')');
RUN ;

 LOG

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 "&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 "&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 &nm. ;
31   	infile "&edg_sup.&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 &nm.
56   				where not(missing(dos))
57   			) ;
58   	QUIT ;
59   	
60   	%do i = &&min_yr. %to &&max_yr. ;
61   
62   		%let _len_j = %eval(%sysfunc(countc(&issuer_ids.,/)) + 1) ;
63   
64   		%do jj = 1 %to &_len_j. ;
65   			
66   			%let issuer = %scan(&issuer_ids.,&jj.) ;
67   
68   			proc sql ;
69   			create table tmp_&nm._&i._&issuer. as
70   			select distinct a.*
71   			from &nm. a
72   			inner join kb.edg_med_&i._&issuer. b /*submitted edge data*/
73   				on a.clm_nbr = b.edg_claim_id
74   			where b.au_lst_adj = 'Y' and year(dos) = &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.&nm._&i._&issuer. (keep = csr_nbr clm_nbr dos dx_code status)
83   				edg_sup.&nm._fiu_&i._&issuer. (keep = region_code mrn dos clm_nbr purpose diagnosis_code rename = (clm_nbr = edg_claim_id) );
84   			  SET tmp_&nm._&i._&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.&nm._&i._fiu_&issuer.
102  			  outfile = "&edg_sup.edge_&nm._&i._fiu_&issuer._&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:  && resolves to &.
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: &&min_yr. 
ERROR: The %FROM value of the %DO I loop is invalid.
SYMBOLGEN:  && resolves to &.
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: &&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:  && resolves to &.
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: &&min_yr. 
ERROR: The %FROM value of the %DO I loop is invalid.
SYMBOLGEN:  && resolves to &.
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: &&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:  && resolves to &.
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: &&min_yr. 
ERROR: The %FROM value of the %DO I loop is invalid.
SYMBOLGEN:  && resolves to &.
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: &&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:  && resolves to &.
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: &&min_yr. 
ERROR: The %FROM value of the %DO I loop is invalid.
SYMBOLGEN:  && resolves to &.
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: &&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
      

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

CALL EXECUTE presents some tough timing issues.  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.  That throws off your logic, as the %do jj=1 %to .... executes before SQL creates your macro variables.

 

You can fix the issue (delaying the execution of macro statements within the code called by CALL EXECUTE) with one change:

 

call execute('%nrstr(%impt('||fl_nm||'))');

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26
SYMBOLGEN:  && resolves to &.
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: &&min_yr. 
ERROR: The %FROM value of the %DO I loop is invalid.

It doesn't like &&MIN_YR. I don't know, as I haven't gone through your code in detail, why you need a && instead of &. Why do you use a &&?

--
Paige Miller
Astounding
PROC Star

CALL EXECUTE presents some tough timing issues.  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.  That throws off your logic, as the %do jj=1 %to .... executes before SQL creates your macro variables.

 

You can fix the issue (delaying the execution of macro statements within the code called by CALL EXECUTE) with one change:

 

call execute('%nrstr(%impt('||fl_nm||'))');
kb011235
Obsidian | Level 7

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. 

Tom
Super User Tom
Super User

This line in your macro:

	%do i = &&min_yr. %to &&max_yr. ;

Is trying to reference macro variables created by the earlier PROC SQL code:

select max(min(yrs),2016), max(yrs) into :min_yr , :max_yr 
...

But that code has not yet run because your data step is still running.

So just use %NRSTR() to prevent the macro from running while the CALL EXECUTE() statement is running.

call execute(cats('%nrstr(%impt)(',fl_nm,')'));

In addition to fixing the timing issue it will also make your SAS log more readable.  Instead of this gibberish:

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 ;

You will see:

NOTE: CALL EXECUTE generated line.
1   + %impt(supp_thrombo)

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 958 views
  • 4 likes
  • 4 in conversation