<?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: Print marco variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Print-marco-variable/m-p/788485#M252115</link>
    <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068" target="_self"&gt;Maxim 2&lt;/A&gt;: Read the log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1     data test;
2     /*   store="Susan's Office Supplies";*/
3        store="Susan's store.";
4        call symput('s',store);
5     run;

NOTE: The data set WORK.TEST has 1 observations and 1 variables.
NOTE: Compressing data set WORK.TEST increased size by 100.00 percent.
      Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: DATA statement used (Total process time):
      real time           0.05 seconds
      cpu time            0.06 seconds


6
7     %macro readit;
8        %if %bquote(&amp;amp;s) ne %then %put *** valid ***;
9        %else %put *** null value ***;
10    %mend readit;
11
12
13    %readit
*** valid ***
14
15    DATA getting_I_want;
16    I_want = SYMGET('readit');
17    I_want_c = "&amp;amp;readit";
WARNING: Apparent symbolic reference READIT not resolved.
18    run;

&lt;FONT color="#FF0000"&gt;NOTE: Invalid argument to function SYMGET('readit') at line 16 column 10.&lt;/FONT&gt;
I_want=  I_want_c=&amp;amp;readit _ERROR_=1 _N_=1
NOTE: The data set WORK.GETTING_I_WANT has 1 observations and 2 variables.
NOTE: Compressing data set WORK.GETTING_I_WANT increased size by 100.00 percent.
      Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
&lt;/PRE&gt;
&lt;P&gt;You have not created a macro variable named &amp;amp;READIT and so your code doesn't work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an alternative that does create a macro variable named &amp;amp;READIT and does work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro readit;
   %global readit;
   %if %bquote(&amp;amp;s) ne %then %let readit= *** valid ***;
   %else %let readit= *** null value ***;
%mend readit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Jan 2022 15:49:57 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-01-05T15:49:57Z</dc:date>
    <item>
      <title>Print marco variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Print-marco-variable/m-p/788484#M252114</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi, for the marco below&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data test;
/*   store="Susan's Office Supplies";*/
   store="Susan's store.";
   call symput('s',store);
run;

%macro readit;
   %if %bquote(&amp;amp;s) ne %then %put *** valid ***;
   %else %put *** null value ***;
%mend readit;&lt;BR /&gt;

%readit

DATA getting_I_want;
I_want = SYMGET('readit');
I_want_c = "&amp;amp;readit";
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Then I get a result table for&amp;nbsp;GETTING_I_WANT as below:&lt;/P&gt;&lt;P&gt;I_want&amp;nbsp; I_want_c&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;amp;readit&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However I really wanted to see the message uner I_want and I_want_c be "&lt;CODE class=""&gt;*** valid ***&lt;/CODE&gt;".&lt;/P&gt;&lt;P&gt;How do I modify my code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 15:33:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Print-marco-variable/m-p/788484#M252114</guid>
      <dc:creator>sarahzhou</dc:creator>
      <dc:date>2022-01-05T15:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: Print marco variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Print-marco-variable/m-p/788485#M252115</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068" target="_self"&gt;Maxim 2&lt;/A&gt;: Read the log&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1     data test;
2     /*   store="Susan's Office Supplies";*/
3        store="Susan's store.";
4        call symput('s',store);
5     run;

NOTE: The data set WORK.TEST has 1 observations and 1 variables.
NOTE: Compressing data set WORK.TEST increased size by 100.00 percent.
      Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: DATA statement used (Total process time):
      real time           0.05 seconds
      cpu time            0.06 seconds


6
7     %macro readit;
8        %if %bquote(&amp;amp;s) ne %then %put *** valid ***;
9        %else %put *** null value ***;
10    %mend readit;
11
12
13    %readit
*** valid ***
14
15    DATA getting_I_want;
16    I_want = SYMGET('readit');
17    I_want_c = "&amp;amp;readit";
WARNING: Apparent symbolic reference READIT not resolved.
18    run;

&lt;FONT color="#FF0000"&gt;NOTE: Invalid argument to function SYMGET('readit') at line 16 column 10.&lt;/FONT&gt;
I_want=  I_want_c=&amp;amp;readit _ERROR_=1 _N_=1
NOTE: The data set WORK.GETTING_I_WANT has 1 observations and 2 variables.
NOTE: Compressing data set WORK.GETTING_I_WANT increased size by 100.00 percent.
      Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
&lt;/PRE&gt;
&lt;P&gt;You have not created a macro variable named &amp;amp;READIT and so your code doesn't work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an alternative that does create a macro variable named &amp;amp;READIT and does work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro readit;
   %global readit;
   %if %bquote(&amp;amp;s) ne %then %let readit= *** valid ***;
   %else %let readit= *** null value ***;
%mend readit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 15:49:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Print-marco-variable/m-p/788485#M252115</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-05T15:49:57Z</dc:date>
    </item>
    <item>
      <title>Re: Print marco variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Print-marco-variable/m-p/788487#M252116</link>
      <description>&lt;P&gt;Adding: if you have SAS 9.4M5 or later, you don't need macro %READIT here, you can use %IF %THEN %ELSE in open code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %bquote(&amp;amp;s) ne %then %do; %let readit= *** valid ***; %end;
%else %do; %let readit= *** null value ***; %end;&lt;/CODE&gt;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 15:55:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Print-marco-variable/m-p/788487#M252116</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-05T15:55:16Z</dc:date>
    </item>
    <item>
      <title>Re: Print marco variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Print-marco-variable/m-p/788505#M252121</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/402346"&gt;@sarahzhou&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at your code, it looks like you are trying to get the result out of the macro readit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Removing &lt;FONT face="courier new,courier"&gt;%put&lt;/FONT&gt; from readit allows you to execute the macro to populate the fixed string value in the data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The below code looks like it achieves what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I assume there is more to your code than you have shared, as no macro code would really be needed to achieve the same result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   /* store="Susan's Office Supplies"; */
   store="Susan's store.";
   call symput('s',store);
run;


%macro readit;
   %if %bquote(&amp;amp;s) ne %then *** valid ***;
   %else *** null value ***;
%mend readit;


data getting_I_want;
   I_want = "%readit";
   I_want_c = "%readit";
run;
&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;Thanks &amp;amp; Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 17:56:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Print-marco-variable/m-p/788505#M252121</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2022-01-05T17:56:24Z</dc:date>
    </item>
  </channel>
</rss>

