Good Morning All,
I am attempting to dynamically allocate a macro variable based on the availability of the macro variable name.
My problem is that for some reason when 2 or more my batch jobs run at the same time the macro variable I am using ("dog" in the example below) gets overridden by the next job. As a result I would like to read in the macro variable "dog" and change it's name to "dog1". If "dog1" is not available then check the availability of "dog2" and so on until an available name is located then specify the value (by resolving "dog").
The code I have written is as follows:
OPTIONS MPRINT MLOGIC SYMBOLGEN;
%LET DOG = SCOTT;
/*%LET DOG1 = CAT;*/
DATA STUFF;
LOOPEND = 1;
DO I = 1 TO LOOPEND;
TEXT = SYMGET('DOG'||TRIM(LEFT(PUT(I,8.))));
IF TEXT = "" THEN CALL SYMPUT('DOG'||TRIM(LEFT(PUT(I,8.))),SYMGET('DOG'));
ELSE LOOPEND +1;
END;
RUN;
%PUT _GLOBAL_;
/*%SYMDEL DOG DOG1 DOG2 DOG3 DOG4;*/
Any help you could offer would be greatly appreciated. Thank you for your time.
Regards,
Scott