I have a macro variable, which contains a list of character strings. I am wondering if there is any way to get a series of new macro variables from that. To illustrate with an example:
I have: %let old_list = a b c d ; * a, b, c, d are the variable names in my model;
I want following 3 new macro variables so that I can refit the model with new list:
%let new_list1 = b c d;
%let new_list2 = a c d;
%let new_list3 = a b c;
I really appreciate any help on getting this. Thanks.
This is more of a macro usage question than a stored process question. Your best bet for a solution might be to contact Tech Support for help with a more automated approach or possibly using a multiple value parameter for your stored process.
To "break down" the value in the old_list macro variable, you could use the SCAN function invoked with %SYSFUNC, as shown below:
%let old_list = a b c d ;
%put --------> pieces of old_list &old_list;
%put --------> v1 = &v1;
%put --------> v2 = &v2;
%put --------> v3 = &v3;
%put --------> v4 = &v4;
%put --------> v5 = &v5;
%put ----> Note how v5 is "null" when you have reached;
%put ----> the end of the string contained in old_list;
To see how the SCAN function works, submit the above code from an EG code node or in a SAS Display Manager session. The results from the %PUT statements will appear in the SAS log. When you run this code snippet, you will see that I have created 5 separate macro variables -- &v1 thru &v4 have the values that were parsed out of &old_list and v5 is "null" because there was no 5th value in the string.
To really code a robust solution for your stored process so you can build multiple model statements, you will probably need a macro program and a macro %do loop (at the very least). Tech Support can help you with those. To contact Tech Support, refer to: http://support.sas.com/techsup/contact/index.html