|
Stephen, you might want to post some sample data and an example of what you
want as a result. The short answer is that macros can't operate based on
values in the same data step, just names, so for example if you have a
variable that contains the name of another list of variables as its value,
you cannot use that value to operate on those variables in the same data
step.
Depending on what you want to do, there are several ways of getting around
that.
For example, if you want a macro to do something to a list of variables,
first use PROC SQL to pull that list of variables into a macro call using
something like this:
proc sql;
select cats('%macroname(',name,')') into :macrocallist separated by ' '
from dictionary.columns
where upcase(memname)="DATASET"
and name in (... list of names, or other WHERE condition ...);
quit;
data want;
set have;
¯ocallist
run;
But the details vary based on what exactly you're doing.
-Joe
On Thu, Feb 12, 2009 at 1:09 PM, StephenTGallagher@gmail.com <
StephenTGallagher@gmail.com> wrote:
> I want to run a macro n times, so I put it in a do loop. No prob. I
> want the macro to process column 1, then column 2, etc, of a sas data
> set (already loaded) but referring to them by their actual column
> names (e.g., First, Last, Phone, Zip…). I have an array that contains
> the column names, and I call the macro in the loop with name{i} passed
> for parameter y. In the macro, I run a proc containing a modeling
> statement model y = v1 v2 v1*v2...; where v1, v2 are other column
> names in the data set. It all fails because the param y in the macro
> is getting the string "name{i}" and not the value of array element I,
> so my statement becomes model names{i} = v1 v2 v1*v2...; Since the
> array itself is not visible within the macro, it chokes. What is the
> "standard" way to do this kind of thing? Thanks for any guidance.
>
|