<?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: problems to resolve macro-variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/problems-to-resolve-macro-variable/m-p/924383#M41480</link>
    <description>&lt;P&gt;typo.&lt;/P&gt;</description>
    <pubDate>Mon, 15 Apr 2024 14:22:06 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-04-15T14:22:06Z</dc:date>
    <item>
      <title>problems to resolve macro-variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/problems-to-resolve-macro-variable/m-p/924333#M41470</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;I can´t resolve macro variable &lt;STRONG&gt;created by SYMPUT routine.&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%macro X2N(id,nombre,edad);
	title "Bienvenido %upcase(&amp;amp;nombre), hoy es &amp;amp;sysdate9.";
data _null_;
	call symput('now',put(time(),time5.));
run;

proc print data=y;
run;
%mend X2N;

%put NOTE- Bienvenido son las &amp;amp;now;
%x2n(5,pablo,23);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I get the error message: "WARNING: Apparent symbolic reference NOW not resolved.", but I don't understand why I get this message&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Anyone can advise me about it??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2024 11:18:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/problems-to-resolve-macro-variable/m-p/924333#M41470</guid>
      <dc:creator>ppinedo</dc:creator>
      <dc:date>2024-04-15T11:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: problems to resolve macro-variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/problems-to-resolve-macro-variable/m-p/924336#M41471</link>
      <description>&lt;P&gt;&amp;amp;NOW exists inside macro %X2N, because that's where it was created. It does not exist outside of macro %X2N;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition, you are trying to use &amp;amp;NOW before it is created (the %PUT statement comes before the call to macro %X2N).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will work, but may not be what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro X2N(id,nombre,edad);

data _null_;
	call symput('now',put(time(),time5.));
run;
%put NOTE- Bienvenido son las &amp;amp;now &amp;amp;=hora;

title "Bienvenido %upcase(&amp;amp;nombre), hoy es &amp;amp;sysdate9.";

proc print data=y;
run;
%mend X2N;

%x2n(5,pablo,23)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Apr 2024 12:42:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/problems-to-resolve-macro-variable/m-p/924336#M41471</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-04-15T12:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: problems to resolve macro-variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/problems-to-resolve-macro-variable/m-p/924352#M41475</link>
      <description>&lt;P&gt;Two issues.&lt;/P&gt;
&lt;P&gt;1) You %PUT is before you call the macro that would create NOW.&lt;/P&gt;
&lt;P&gt;2) Unless you have created the macro variable NOW before you call the macro then the macro variable NOW it creates will be LOCAL to the macro and no longer exist when the macro finishes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can either define the macro variable before calling the macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let now=;
%x2n(5,pablo,23);
%put NOTE- Bienvenido son las &amp;amp;now;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or change the macro to make sure it doesn't define NOW as logic.&amp;nbsp; The quick (and dirty) method is to use the optional third argument to CALL SYMPUTX().&amp;nbsp; NOTE: unless there is some strange reason that you need the macro variable to have leading and/or trailing spaces you should never use the ancient CALL SYMPUT() method.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro X2N(id,nombre,edad);
title "Bienvenido %upcase(&amp;amp;nombre), hoy es &amp;amp;sysdate9.";
data _null_;
  call symputX('now',put(time(),time5.),'g');
run;

proc print data=y;
run;
%mend X2N;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;NOTE: If you want NOW to include leading zero when time() is before 10AM then use TOD format instead of TIME format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the better solution would be to only define NOW as GLOBAL when it does not already exist.&amp;nbsp; Then you could call this macro from another macro that has a LOCAL macro variable named NOW and be able to see the results.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro X2N(id,nombre,edad);
%if not %symexist(now) %then %global now;
title "Bienvenido %upcase(&amp;amp;nombre), hoy es &amp;amp;sysdate9.";
data _null_;
  call symputX('now',put(time(),time5.));
run;

proc print data=y;
run;
%mend X2N;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2024 12:47:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/problems-to-resolve-macro-variable/m-p/924352#M41475</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-15T12:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: problems to resolve macro-variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/problems-to-resolve-macro-variable/m-p/924379#M41479</link>
      <description>&lt;P&gt;Thanks for you reply&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt; &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;, you are right, macro-variable is&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;LOCAL to the macro&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What do you mean&amp;nbsp; "&amp;nbsp;to make sure it doesn't define NOW as logic"&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;?? what is "logic"??&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 15 Apr 2024 14:12:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/problems-to-resolve-macro-variable/m-p/924379#M41479</guid>
      <dc:creator>ppinedo</dc:creator>
      <dc:date>2024-04-15T14:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: problems to resolve macro-variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/problems-to-resolve-macro-variable/m-p/924383#M41480</link>
      <description>&lt;P&gt;typo.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2024 14:22:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/problems-to-resolve-macro-variable/m-p/924383#M41480</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-15T14:22:06Z</dc:date>
    </item>
  </channel>
</rss>

