should it be "lastvar" or "last.var"? I made the fixes both of you suggested but still get the error.... this is now my log 1038 proc sql; 1039 create table fishdata as select fish_I, fins, sea_depth 1040 from blue.fishdata; NOTE: Table WORK.FISHDATA created, with 9 rows and 3 columns. 1041 quit; NOTE: PROCEDURE SQL used (Total process time): real time 0.26 seconds cpu time 0.00 seconds 1042 1043 1044 1045 %let dsname=fishdata; 1046 %macro check(dsname,var); 1047 %let dsid=%sysfunc(open(&dsname)); 1048 %let countnum=%sysfunc(varnum(&dsid,&var)); 1049 %let rc=%sysfunc(close(&dsid)); 1050 1051 %if &countnum>0 %then %do; 1052 proc contents data=&dsname; 1053 run; 1054 %end; 1055 %else %if &countnum<0 %then %do; 1056 proc sql; 1057 select fish_I 1058 from &dsname; 1059 quit; 1060 1061 %end; 1062 %mend check; 1063 options mprint mlogic symbolgen; 1064 %check(&dsname,lastvar); MLOGIC(CHECK): Beginning execution. SYMBOLGEN: Macro variable DSNAME resolves to fishdata MLOGIC(CHECK): Parameter DSNAME has value fishdata MLOGIC(CHECK): Parameter VAR has value lastvar MLOGIC(CHECK): %LET (variable name is DSID) SYMBOLGEN: Macro variable DSNAME resolves to fishdata MLOGIC(CHECK): %LET (variable name is COUNTNUM) SYMBOLGEN: Macro variable DSID resolves to 3 SYMBOLGEN: Macro variable VAR resolves to lastvar MLOGIC(CHECK): %LET (variable name is RC) SYMBOLGEN: Macro variable DSID resolves to 3 SYMBOLGEN: Macro variable COUNTNUM resolves to 0 MLOGIC(CHECK): %IF condition &countnum>0 is FALSE SYMBOLGEN: Macro variable COUNTNUM resolves to 0 MLOGIC(CHECK): %IF condition &countnum<0 is FALSE MLOGIC(CHECK): Ending execution. 1065 proc sql; 1066 create table fishdata as select fish_I, fins, sea_depth 1067 from blue.fishdata; NOTE: Table WORK.FISHDATA created, with 9 rows and 3 columns. 1068 quit; NOTE: PROCEDURE SQL used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 1069 1070 1071 1072 %let dsname=fishdata; 1073 1074 1075 proc sql; 1076 create table &dsname as select * SYMBOLGEN: Macro variable DSNAME resolves to fishdata 1077 from blue.fishdatas; NOTE: Table WORK.FISHDATA created, with 9 rows and 3 columns. 1078 quit; NOTE: PROCEDURE SQL used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 1079 1080 %macro check(dsname,var); 1081 %let dsid=%sysfunc(open(&dsname)); 1082 %let countnum=%sysfunc(varnum(&dsid,&var)); 1083 %let rc=%sysfunc(close(&dsid)); 1084 1085 %if &countnum>0 %then %do; 1086 proc contents data=&dsname; 1087 run; 1088 %end; 1089 %else %if &countnum<0 %then %do; 1090 proc sql; 1091 select fish_I 1092 from &dsname; 1093 quit; 1094 1095 %end; 1096 %mend check; 1097 options mprint mlogic symbolgen; 1098 %check(&dsname,last.var); MLOGIC(CHECK): Beginning execution. SYMBOLGEN: Macro variable DSNAME resolves to fishdata MLOGIC(CHECK): Parameter DSNAME has value fishdata MLOGIC(CHECK): Parameter VAR has value last.var MLOGIC(CHECK): %LET (variable name is DSID) SYMBOLGEN: Macro variable DSNAME resolves to fishdata MLOGIC(CHECK): %LET (variable name is COUNTNUM) SYMBOLGEN: Macro variable DSID resolves to 3 SYMBOLGEN: Macro variable VAR resolves to last.var WARNING: Argument 2 to function VARNUM referenced by the %SYSFUNC or %QSYSFUNC macro function is out of range. NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The result of the operations have been set to a missing value. MLOGIC(CHECK): %LET (variable name is RC) SYMBOLGEN: Macro variable DSID resolves to 3 SYMBOLGEN: Macro variable COUNTNUM resolves to . MLOGIC(CHECK): %IF condition &countnum>0 is FALSE SYMBOLGEN: Macro variable COUNTNUM resolves to . MLOGIC(CHECK): %IF condition &countnum<0 is TRUE MPRINT(CHECK): proc sql; SYMBOLGEN: Macro variable DSNAME resolves to fishdata MPRINT(CHECK): select fish_I from fishdata; MPRINT(CHECK): quit; NOTE: PROCEDURE SQL used (Total process time): real time 0.01 seconds cpu time 0.00 seconds MLOGIC(CHECK): Ending execution.
... View more