[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    macro resolving question
From:       Tim Berryhill <000008c2afdd9bfa-dmarc-request () LISTSERV ! UGA ! EDU>
Date:       2022-10-21 14:42:10
Message-ID: a66a1ba9960d42e9a1b279e6b058c750 () wellsfargo ! com
[Download RAW message or body]

Perhaps you simplified the problem for the example.  Odd numbers of ampersands are \
occasionally valuable (essentially building a multi-dimensional array of macro \
variables), so I am glad Joe showed that solution, but your example problem does not \
require &&&.

The %let statement in open code (outside any macro definition) establishes a global \
macro variable.  It will be available inside the macro without passing it as a \
parameter.   You could code:
%macro pdf/minoperator;
%put &=deno1;
%mend pdf;
options mprint;

%let deno1=Non-Hispanic American Indian or Alaska Native Children with Services \
Authorized on IFSP (Denominator); %pdf

Alternatively, you could code:
%macro pdf (deno1)/minoperator;
%put &=deno1;
%mend pdf;
options mprint;

%pdf(Non-Hispanic American Indian or Alaska Native Children with Services Authorized \
on IFSP (Denominator));


In the second version, you might need macro quoting for the parentheses in the value, \
so that the first closing parenthesis was not taken as the end of the macro \
invocation.  You can actually omit the trailing semicolon on the macro invocation--I \
did in the first example--but it rarely hurts and it comforts some people.  It also \
avoids a mistake when you have a stack of macro invocations and try to change the \
                percents to asterisks for the ones you do not want in a specific run.
-----Original Message-----
Date:    Thu, 20 Oct 2022 18:14:52 +0000
From:    "Zhu, Bin (HEALTH)" <bin.zhu@HEALTH.NY.GOV>
Subject: macro resolving question

Good afternoon All,

I have following SAS code:

%macro pdf (deno1)/minoperator;
%put &=deno1;

%mend pdf;
options mprint;

%let deno1=Non-Hispanic American Indian or Alaska Native Children with Services \
Authorized on IFSP (Denominator); %pdf("deno1");

It does not work as the log shows:
DENO1="deno1"

Would you please let me know how to make this works?  Many thanks for your help.

Bin


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic