Hi, I have using sas macro to check the current system time and do calculations based on it. However, I am getting an error. Can someone point out if I have incorrect data usage? %global timeflag tc; %macro _timecheck; data _null_; call symput ('tc',strip(minute(time()))); run; %put "&tc is the system time" ; %if 0<= &tc <= 29 %then %do; %let timeflag = A ; %put "the flag is set to &timeflag"; %end; %else %if 30<= &tc <= 59 %then %do; %let timeflag = B; %put "the flag is set to &timeflag"; %end; %mend _timecheck; %_timecheck (CATS('PBG',LEFT(put(t2.&prcname.Plant,11.),2), SUBSTR(t2.&prcname.Line,1,1))) LABEL="&prcname. Unit" AS &prcname.Unit, /* _30mintime */ (PUT(round(t2.&prcname.Time,hms(0,30,00)), DATETIME.)) LABEL="&prcname._30mintime" AS &prcname._30mintime, /* _1hrtime */ (PUT(round(intnx('hour',t2.&prcname.Time,-1 )), DATETIME.) ) LABEL="&prcname._1hrtime" AS &prcname._1hrtime, /* _daytime */ (put(datepart(t2.&prcname.Time), MMDDYY10.)) LABEL="&prcname._daytime" AS &prcname._daytime, /* _CustomHrBin */ (CASE WHEN ( &timeflag = A) and ( 0<= (minute(t2.&prcname.Time)) <= 29 ) THEN PUT(round(t2.&prcname.Time,hms(1,0,00)), DATETIME.) WHEN ( &timeflag = A) and ( 30<= (minute(t2.&prcname.Time)) <= 59 ) then PUT(intnx('hour' ,round(t2.&prcname.Time,hms(1,0,00)),-1), DATETIME.) when ( &timeflag = B) and ( 0<= (minute(t2.&prcname.Time)) <= 29 ) then PUT(intnx('minutes', round(t2.&prcname.Time,hms(1,0,00)), -30),DATETIME.) when ( &timeflag = B) and ( 30<= (minute(t2.&prcname.Time)) <= 59 ) then PUT(intnx('minute' ,round(t2.&prcname.Time,hms(1,0,00)),-30),DATETIME.) END ) AS _&prcname._CustomHrBin SYMBOLGEN: Macro variable PRCNAME resolves to FinalSim "the currenct process being executed is FinalSim" SYMBOLGEN: Macro variable PRCNAME resolves to FinalSim SYMBOLGEN: Macro variable TIMEFLAG resolves to A WARNING: Function LEFT requires at most 1 argument(s). The extra one(s) will be ignored. NOTE: A CASE expression has no ELSE clause. Cases not accounted for by the WHEN clauses will result in a missing value for the CASE expression. ERROR: The following columns were not found in the contributing tables: A, B. NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements. MPRINT(_BUILD_METRICS): QUIT; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE SQL used (Total process time): real time 0.00 seconds cpu time 0.00 seconds The case statement above worked before substituting the macro variable. Thanks, Raj.
... View more