<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to get macro variable value in quotations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709277#M218077</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/117414"&gt;@chinna0369&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Okay, if I create macro variable inside quotes as "&amp;amp;var2" How can I give special characters such as %, (, ). etc. So I have created &amp;amp;var2 like above.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please show us how this macro variable &amp;amp;var2 will be used inside the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Jan 2021 18:57:36 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-01-04T18:57:36Z</dc:date>
    <item>
      <title>How to get macro variable value in quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709270#M218072</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like get macro variable value in quotations in below, I am using as below but its not working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%getnum(var1=PSA ne ., var2=%str("PSA BY MEDIAN (&amp;amp;median.)"), nn=);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any solutions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Nyala&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 18:38:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709270#M218072</guid>
      <dc:creator>chinna0369</dc:creator>
      <dc:date>2021-01-04T18:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to get macro variable value in quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709272#M218073</link>
      <description>&lt;P&gt;What is not working?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 18:44:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709272#M218073</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-01-04T18:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to get macro variable value in quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709273#M218074</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/117414"&gt;@chinna0369&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like get macro variable value in quotations in below, I am using as below but its not working.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%getnum(var1=PSA ne ., var2=%str("PSA BY MEDIAN (&amp;amp;median.)"), nn=);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Any solutions?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;How will this macro variable &amp;amp;var2 be used inside of %GETNUM?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Usually, it's not necessary to have macro variable values enclosed in quotes or in double-quotes, that just complicates things. Typically, inside the macro you can just refer to &amp;amp;var2, if you need it in quotes, as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&amp;amp;var2"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;which is much simpler than trying to get quotes around it above as you are trying to do.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 18:46:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709273#M218074</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-01-04T18:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to get macro variable value in quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709274#M218075</link>
      <description>&lt;P&gt;I not getting actual macro variable value in quotations, I am getting as "PSA BY MEDIAN (&amp;amp;median.)".&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 18:48:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709274#M218075</guid>
      <dc:creator>chinna0369</dc:creator>
      <dc:date>2021-01-04T18:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to get macro variable value in quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709275#M218076</link>
      <description>Okay, if I create macro variable inside quotes as "&amp;amp;var2" How can I give special characters such as %, (, ). etc. So I have created &amp;amp;var2 like above.</description>
      <pubDate>Mon, 04 Jan 2021 18:52:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709275#M218076</guid>
      <dc:creator>chinna0369</dc:creator>
      <dc:date>2021-01-04T18:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to get macro variable value in quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709277#M218077</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/117414"&gt;@chinna0369&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Okay, if I create macro variable inside quotes as "&amp;amp;var2" How can I give special characters such as %, (, ). etc. So I have created &amp;amp;var2 like above.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please show us how this macro variable &amp;amp;var2 will be used inside the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 18:57:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709277#M218077</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-01-04T18:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to get macro variable value in quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709280#M218078</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/117414"&gt;@chinna0369&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Okay, if I create macro variable inside quotes as "&amp;amp;var2" How can I give special characters such as %, (, ). etc. So I have created &amp;amp;var2 like above.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It is really not at all clear what your question is.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is example of referencing a macro variables value inside of double quotes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let vara=Text of vara;
%let varb=&amp;amp;vara;
%let varc="&amp;amp;vara";
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Why did you include the %STR() in your original question?&amp;nbsp; Are you worried that the value of VARA has commas or other characters that have special meaning in the macro call?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 19:01:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709280#M218078</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-04T19:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to get macro variable value in quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709282#M218079</link>
      <description>&lt;P&gt;Below is the macro I have written for counts, and callings&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;** Get counts and create macro to repeat for every variable;
%macro getnum(out=, var1=, var2=, nn=);
%if 0=%length(&amp;amp;nn) %then %do;
  %global seq ;
  %let seq=%eval(&amp;amp;seq+1);
  %let nn=&amp;amp;seq;
%end;
%if 0=%length(&amp;amp;out) %then %let out=out&amp;amp;nn ;

proc sql;
	create table stp1 as
	select distinct trtpn, count(distinct usubjid) as n,
	case when trtpn=1 then strip(put(calculated n, 3.))||" ("||strip(put((calculated n/&amp;amp;n1.)*100, 5.1))||")"
     	 when trtpn=2 then strip(put(calculated n, 3.))||" ("||strip(put((calculated n/&amp;amp;n2.)*100, 5.1))||")"
    	 when trtpn=9 then strip(put(calculated n, 3.))||" ("||strip(put((calculated n/&amp;amp;n3.)*100, 5.1))||")"
         else ""
	end as numm
	from adsl1
	where &amp;amp;var1.
	group by trtpn;
quit;

proc transpose data=stp1 out=stp2;
	var numm;
	id trtpn;
run;

data &amp;amp;out.;
	length v1 v2 v3 v4 $200.;
	set stp2;

	v1=&amp;amp;var2.;
	v2=_1;
	v3=_2;
	v4=_9;

	ord=&amp;amp;nn.;

	keep ord v1-v4;
run;
%mend;
%getstats(var1=tidist, var2=%str(TIME FROM INITIAL DIAGNOSIS TO INITIATION OF STUDY THERAPY (YEARS)), nn=, mm=);
%getnum(var1=TIDISTC ne '', var2=%unquote("TIME FROM INITIAL DIAGNOSIS TO INITIATION OF STUDY THERAPY (%)"), nn=);
%getnum(var1=PSA ne ., var2=%str("PSA BY MEDIAN (&amp;amp;median.)"), nn=);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Jan 2021 19:04:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709282#M218079</guid>
      <dc:creator>chinna0369</dc:creator>
      <dc:date>2021-01-04T19:04:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to get macro variable value in quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709285#M218081</link>
      <description>&lt;P&gt;Yes, because of special characters I am using %str, %unquote. I have given my whole code in one of my replies.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 19:07:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709285#M218081</guid>
      <dc:creator>chinna0369</dc:creator>
      <dc:date>2021-01-04T19:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to get macro variable value in quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709286#M218082</link>
      <description>&lt;P&gt;Since I don't have your input data sets or the other macro, here is an abbreviated piece of code that handles &amp;amp;var2 properly&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro getnum(out=, var1=, var2=, nn=);
data _a_;
	length v1 v2 v3 v4 $200.;
	set sashelp.class;
	v1="&amp;amp;var2";
	keep v1-v4;
run;
%mend;
%getnum(var2=TIME FROM INITIAL DIAGNOSIS TO INITIATION OF STUDY THERAPY %nrstr(%%));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have another question. &amp;amp;var2 equals TIME FROM INITIAL DIAGNOSIS TO INITIATION OF STUDY THERAPY %. Why is this a variable in a data set, since it never varies? Shouldn't it be a label or a title?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 19:16:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709286#M218082</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-01-04T19:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to get macro variable value in quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709288#M218083</link>
      <description>&lt;P&gt;Okay, got it. Thank you so much. But I have one more question. Can I use &amp;amp;median. like below? But it looks like it is not working properly? I mean &amp;amp;median. value is not taking in below var1 macro variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;** Median calculation for counts category untill a variable created in ADSL;
proc sql noprint;
	select v4 into :median from out59 where v1 eq '~{nbspace 5}MEDIAN';
quit;	
%put &amp;amp;median.;
** PSA BY MEDIAN (XXXX);
%getnum(var1=PSA ne ., var2=%str("PSA BY MEDIAN (&amp;amp;median.)"), nn=);
%getnum(var1=PSA &amp;lt; &amp;amp;median., var2=%str("~{nbspace 5}&amp;lt; MEDIAN"), nn=);
%getnum(var1=PSA &amp;gt;= &amp;amp;median., var2=%str("~{nbspace 5}&amp;gt;= MEDIAN"), nn=);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Sorry for the confusion.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 19:18:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709288#M218083</guid>
      <dc:creator>chinna0369</dc:creator>
      <dc:date>2021-01-04T19:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to get macro variable value in quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709293#M218085</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/117414"&gt;@chinna0369&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Okay, got it. Thank you so much. But I have one more question. Can I use &amp;amp;median. like below? But it looks like it is not working properly? I mean &amp;amp;median. value is not taking in below var1 macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;** Median calculation for counts category untill a variable created in ADSL;
proc sql noprint;
	select v4 into :median from out59 where v1 eq '~{nbspace 5}MEDIAN';
quit;	
%put &amp;amp;median.;
** PSA BY MEDIAN (XXXX);
%getnum(var1=PSA ne ., var2=%str("PSA BY MEDIAN (&amp;amp;median.)"), nn=);
%getnum(var1=PSA &amp;lt; &amp;amp;median., var2=%str("~{nbspace 5}&amp;lt; MEDIAN"), nn=);
%getnum(var1=PSA &amp;gt;= &amp;amp;median., var2=%str("~{nbspace 5}&amp;gt;= MEDIAN"), nn=);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Sorry for the confusion.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What is not working? Please show us the log from when you run %GETNUM by including this command&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;above the line that begins with %getnum, then running that line and %getnum together. Show us the full unedited unchopped complete log as it appears for %GETNUM, in the sequendce that it appears in the LOG.&amp;nbsp;&lt;STRONG&gt;Copy the log as text, and then paste it into the window that appears when you click on the &amp;lt;/&amp;gt; icon. &lt;FONT color="#FF0000"&gt;DO NOT SKIP THIS STEP&lt;/FONT&gt;.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 19:29:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709293#M218085</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-01-04T19:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to get macro variable value in quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709295#M218087</link>
      <description>&lt;P&gt;Here is the log:&lt;/P&gt;&lt;PRE&gt;217    ***************
218    **** Stats ****
219    **************;
220    ** Get descriptive stats and create macro to repeat for every variable;
221    %macro getstats(out=, var1=, var2=, nn=, mm=);
222    %if 0=%length(&amp;amp;nn) %then %do;
223      %global seq ;
224      %let seq=%eval(&amp;amp;seq+1);
225      %let nn=&amp;amp;seq;
226      %let mm=&amp;amp;seq-0.5;
227    %end;
228    %if 0=%length(&amp;amp;out) %then %let out=out&amp;amp;nn ;
229
230    proc means data=adsl;
231    var &amp;amp;var1.;
232    class trtpn;
233    output out=step1 n=count mean=mn std=std median=mdn q1=qtr1 q3=qtr3 min=mini max=maxi;
234    run;
235
236    data step2;
237    set step1(where=(trtpn ne .));
238    if count ne . then cnt=strip(put(count,8.));
239    else cnt='';
240    if mn ne . then mnsd=strip(put(mn,8.));*||" ("||strip(put(std,8.1))||")";
241    else mnsd='';
242    if mdn ne . then mdian=strip(put(mdn,8.));
243    else mdian='';
244    if qtr3 ne . then qtrs=strip(put(qtr1,8.))||", "||strip(put(qtr3,8.));
245    else qtrs='';
246    if mini ne . and maxi ne . then minmax=strip(put(mini,8.))||", "||strip(put(maxi,8.));
247    else minmax='';
248    if std ne . then stdev=strip(put(std,8.));
249    else stdev='';
250    keep trtpn cnt mnsd mdian qtrs minmax stdev;
251    run;
252
253    proc transpose data=step2 out=step3;
254    var cnt mnsd mdian qtrs minmax stdev;
255    id trtpn;
256    run;
257
258    data step4;
259    length v1 v2 v3 v4 $200.;
260    set step3;
261
262    if _NAME_ eq "cnt" then v1="~{nbspace 5}N";
263    else if _NAME_ eq "mnsd" then v1="~{nbspace 5}MEAN";
264    else if _NAME_ eq "mdian" then v1="~{nbspace 5}MEDIAN";
265    else if _NAME_ eq "qtrs" then v1="~{nbspace 5}Q1, Q3";
266    else if _NAME_ eq "minmax" then v1="~{nbspace 5}MIN, MAX";
267    else if _NAME_ eq "stdev" then v1="~{nbspace 5}STANDARD DEVIATION";
268
269    v2=_1;
270    v3=_2;
271    v4=_9;
272
273    ord=&amp;amp;nn.;
274
275    keep ord v1 v2 v3 v4;
276    run;
277
278    data dummy;
279        v1="&amp;amp;var2";
280        ord=&amp;amp;mm.;
281    run;
282
283    data &amp;amp;out.;
284        set step4 dummy;
285        by ord;
286    run;
287    %mend getstats;
288
289    ************
290    ** counts **
291    ***********;
292    ** Get counts and create macro to repeat for every variable;
293    %macro getnum(out=, var1=, var2=, nn=);
294    %if 0=%length(&amp;amp;nn) %then %do;
295      %global seq ;
296      %let seq=%eval(&amp;amp;seq+1);
297      %let nn=&amp;amp;seq;
298    %end;
299    %if 0=%length(&amp;amp;out) %then %let out=out&amp;amp;nn ;
300
301    proc sql;
302        create table stp1 as
303        select distinct trtpn, count(distinct usubjid) as n,
304        case when trtpn=1 then strip(put(calculated n, 3.))||" ("||strip(put((calculated
304  ! n/&amp;amp;n1.)*100, 5.1))||")"
305             when trtpn=2 then strip(put(calculated n, 3.))||" ("||strip(put((calculated
305  ! n/&amp;amp;n2.)*100, 5.1))||")"
306             when trtpn=9 then strip(put(calculated n, 3.))||" ("||strip(put((calculated
306  ! n/&amp;amp;n3.)*100, 5.1))||")"
307             else ""
308        end as numm
309        from adsl1
310        where &amp;amp;var1.
311        group by trtpn;
312    quit;
313
314    proc transpose data=stp1 out=stp2;
315        var numm;
316        id trtpn;
317    run;
318
319    data &amp;amp;out.;
320        length v1 v2 v3 v4 $200.;
321        set stp2;
322
323        v1=&amp;amp;var2.;
324        v2=_1;
325        v3=_2;
326        v4=_9;
327
328        ord=&amp;amp;nn.;
329
330        keep ord v1-v4;
331    run;
332    %mend;
333
334    %let seq=0;
421    ** Median calculation for counts category untill a variable created in ADSL;
422    proc sql noprint;
423        select v4 into :median from out59 where v1 eq '~{nbspace 5}MEDIAN';
NOTE: No rows were selected.
424    quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.01 seconds
      user cpu time       0.00 seconds
      system cpu time     0.01 seconds
      memory              5684.12k
      OS Memory           29948.00k
      Timestamp           01/04/2021 02:36:14 PM
      Step Count                        205  Switch Count  0


WARNING: Apparent symbolic reference MEDIAN not resolved.
425    %put &amp;amp;median.;
&amp;amp;median.
426    ** PSA BY MEDIAN (XXXX);
427    %getnum(var1=PSA ne ., var2=%str("PSA BY MEDIAN (&amp;amp;median.)"), nn=);
WARNING: Apparent symbolic reference MEDIAN not resolved.
NOTE: Table WORK.STP1 created, with 3 rows and 3 columns.

NOTE: PROCEDURE SQL used (Total process time):
      real time           0.02 seconds
      user cpu time       0.00 seconds
      system cpu time     0.00 seconds
      memory              5809.00k
      OS Memory           29948.00k
      Timestamp           01/04/2021 02:36:14 PM
      Step Count                        206  Switch Count  0



NOTE: There were 3 observations read from the data set WORK.STP1.
NOTE: The data set WORK.STP2 has 1 observations and 4 variables.
NOTE: PROCEDURE TRANSPOSE used (Total process time):
      real time           0.02 seconds
      user cpu time       0.00 seconds
      system cpu time     0.01 seconds
      memory              2836.21k
      OS Memory           26876.00k
      Timestamp           01/04/2021 02:36:14 PM
      Step Count                        207  Switch Count  0


WARNING: Apparent symbolic reference MEDIAN not resolved.

NOTE: There were 1 observations read from the data set WORK.STP2.
NOTE: The data set WORK.OUT61 has 1 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      user cpu time       0.00 seconds
      system cpu time     0.01 seconds
      memory              1305.84k
      OS Memory           25340.00k
      Timestamp           01/04/2021 02:36:14 PM
      Step Count                        208  Switch Count  0


428    options mprint;
429    %getnum(var1=PSA &amp;lt; &amp;amp;median., var2=%str("~{nbspace 5}&amp;lt; MEDIAN"), nn=);
WARNING: Apparent symbolic reference MEDIAN not resolved.
MPRINT(GETNUM):   proc sql;
WARNING: Apparent symbolic reference MEDIAN not resolved.
NOTE 138-205: Line generated by the macro variable "VAR1".
1       PSA &amp;lt; &amp;amp;median.
              -
              22
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,
              a numeric constant, a datetime constant, a missing value, BTRIM, INPUT, PUT,
              SUBSTRING, USER.

WARNING: Apparent symbolic reference MEDIAN not resolved.
NOTE 137-205: Line generated by the invoked macro "GETNUM".
2       3.))||" ("||strip(put((calculated n/&amp;amp;n2.)*100, 5.1))||")"          when trtpn=9 then
2    ! strip(put(calculated n, 3.))||" ("||strip(put((calculated n/&amp;amp;n3.)*100, 5.1))||")"
2    ! else ""     end as numm     from adsl1     where &amp;amp;var1.     group by trtpn;
                                                                         --
                                                                         22
ERROR 22-322: Syntax error, expecting one of the following: GROUP, ORDER.

NOTE: Line generated by the invoked macro "GETNUM".
2       3.))||" ("||strip(put((calculated n/&amp;amp;n2.)*100, 5.1))||")"          when trtpn=9 then
2    ! strip(put(calculated n, 3.))||" ("||strip(put((calculated n/&amp;amp;n3.)*100, 5.1))||")"
2    ! else ""     end as numm     from adsl1     where &amp;amp;var1.     group by trtpn;
                                                                         --
                                                                         76
ERROR 76-322: Syntax error, statement will be ignored.

MPRINT(GETNUM):   create table stp1 as select distinct trtpn, count(distinct usubjid) as n, case
when trtpn=1 then strip(put(calculated n, 3.))||" ("||strip(put((calculated n/ 3)*100, 5.1))||")"
when trtpn=2 then strip(put(calculated n, 3.))||" ("||strip(put((calculated n/ 4)*100, 5.1))||")"
when trtpn=9 then strip(put(calculated n, 3.))||" ("||strip(put((calculated n/ 7)*100, 5.1))||")"
else "" end as numm from adsl1 where PSA &amp;lt; &amp;amp; group by trtpn;
MPRINT(GETNUM):   quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.08 seconds
      user cpu time       0.01 seconds
      system cpu time     0.04 seconds
      memory              74.84k
      OS Memory           24308.00k
      Timestamp           01/04/2021 02:36:14 PM
      Step Count                        209  Switch Count  0



MPRINT(GETNUM):   proc transpose data=stp1 out=stp2;
MPRINT(GETNUM):   var numm;
MPRINT(GETNUM):   id trtpn;
MPRINT(GETNUM):   run;

NOTE: There were 3 observations read from the data set WORK.STP1.
NOTE: The data set WORK.STP2 has 1 observations and 4 variables.
NOTE: PROCEDURE TRANSPOSE used (Total process time):
      real time           0.02 seconds
      user cpu time       0.00 seconds
      system cpu time     0.01 seconds
      memory              2836.21k
      OS Memory           26876.00k
      Timestamp           01/04/2021 02:36:14 PM
      Step Count                        210  Switch Count  0


MPRINT(GETNUM):   data out62;
MPRINT(GETNUM):   length v1 v2 v3 v4 $200.;
MPRINT(GETNUM):   set stp2;
MPRINT(GETNUM):   v1="~{nbspace 5}&amp;lt; MEDIAN";
MPRINT(GETNUM):   v2=_1;
MPRINT(GETNUM):   v3=_2;
MPRINT(GETNUM):   v4=_9;
MPRINT(GETNUM):   ord=62;
MPRINT(GETNUM):   keep ord v1-v4;
MPRINT(GETNUM):   run;

NOTE: There were 1 observations read from the data set WORK.STP2.
NOTE: The data set WORK.OUT62 has 1 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      user cpu time       0.01 seconds
      system cpu time     0.01 seconds
      memory              1305.71k
      OS Memory           25340.00k
      Timestamp           01/04/2021 02:36:14 PM
      Step Count                        211  Switch Count  0



&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 19:51:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709295#M218087</guid>
      <dc:creator>chinna0369</dc:creator>
      <dc:date>2021-01-04T19:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to get macro variable value in quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709297#M218089</link>
      <description>&lt;P&gt;Your macro is using VAR2 in only one place:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	v1=&amp;amp;var2.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since you appear to want V1 to be a character variable just include the quotes when calling the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So your examples calls can be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%getnum(var1=TIDISTC ne ' ', var2='TIME FROM INITIAL DIAGNOSIS TO INITIATION OF STUDY THERAPY (%)', nn=);
%getnum(var1=PSA ne ., var2="PSA BY MEDIAN (&amp;amp;median.)", nn=);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Using single quotes for the first example will prevent the macro processor from looking at the % in the value (although I don't think it is actually going to cause any trouble).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are worried about special characters inside of the value of MEDIAN then use %SUPERQ() to add macro quoting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%getnum(var1=PSA ne ., var2="PSA BY MEDIAN (%superq(median))", nn=);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 19:39:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709297#M218089</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-04T19:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to get macro variable value in quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709300#M218091</link>
      <description>&lt;P&gt;I only needed the part of the log where you ran %GETNUM and it didn't work, not the 3000 lines above that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;WARNING: Apparent symbolic reference MEDIAN not resolved.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have not assigned a value to &amp;amp;median&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 19:42:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709300#M218091</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-01-04T19:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to get macro variable value in quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709398#M218133</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;%getnum(var1=PSA ne ., var2=%bquote("PSA BY MEDIAN (&amp;amp;median.)"), nn=)&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Jan 2021 11:56:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709398#M218133</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-01-05T11:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to get macro variable value in quotations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709509#M218191</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, median is not resolved that is the problem here. Now I have updated and it is working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all!&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2021 21:19:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-macro-variable-value-in-quotations/m-p/709509#M218191</guid>
      <dc:creator>chinna0369</dc:creator>
      <dc:date>2021-01-05T21:19:12Z</dc:date>
    </item>
  </channel>
</rss>

