02-28-2017 10:54 AM
[Base SAS 9.4]
I'm using a macro to create and sign-on to some asynchronous tasks with dynamic names. Here's snippet from the macro to illustrate:
%DO i = 1 %TO &num_tasks; %GLOBAL task&i; %LET task&i = &some_value; SIGNON task&i;
I'd like to create one or more additional macros that do some additional processing on any tasks that have been created, but I'm unsure how to obtain a list of the task names. I'm using &num_tasks as a parameter in the macro above, but I'd prefer to obtain a list of the task names because I'm considering adding an environment/server parameter to the macro above and adding a letter before task&i, such as pTask&i, to indicate where the task should be running (and not overwrite existing tasks if the macro was run to create tasks for another environment).
I know I can use LISTTASK _ALL_ to put the list of tasks, with statuses, to my log file, but I'd like to assign the list to some kind of collection, like a dataset or an array, that I can use in my code. Are the list of tasks stored in a SASHELP table/view (i looked all through SASHELP with no luck) or some other way to obtain the tasks?
03-02-2017 05:54 AM
Set up a temp data set with the desired data elements at the beginning of your proces...then just query it prior to running your macro. You can easily pull &num_tasks with a sql query :into a macro variable...and presumably any other data elements for further processing.