<?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: Macro -- resolve to blank in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-resolve-to-blank/m-p/694276#M211724</link>
    <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately, I am still getting the same error if expdose or exdstxt are missing (btw, they are character variables)&lt;/P&gt;
&lt;P&gt;data set_header2;&lt;/P&gt;
&lt;P&gt;set ex;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; where subject = &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"&amp;amp;p_id"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; if not missing(expdose) then call symput(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"headerdose"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,trim(expdose));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; else if not missing(exdstxt) then call symput(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"headerdose"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,trim(exdstxt)); &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; else call symput(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"headerdose"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;, &lt;/FONT&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;STRONG&gt;&lt;FONT size="3" color="#800080"&gt;"" &lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT size="3"&gt;); &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;LOG:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;WARNING: Apparent symbolic reference HEADERDOSE not resolved.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;let me know if you have any other ideas. thanks! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Oct 2020 15:50:34 GMT</pubDate>
    <dc:creator>NJGIRL</dc:creator>
    <dc:date>2020-10-26T15:50:34Z</dc:date>
    <item>
      <title>Macro -- resolve to blank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-resolve-to-blank/m-p/694267#M211719</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I feel like I am missing a basic&amp;nbsp; concept -- I need a macro variable to resolve to missing if the required&amp;nbsp;value is not populated. This is part of&amp;nbsp; a loop. The code loops through each patient (&amp;amp;p_id). eg: &amp;nbsp;If expdose or exdstxt is not valued, then &amp;amp;headerdose should resolve to missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data set_header2;&lt;/P&gt;
&lt;P&gt;set ex;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; where subject = &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"&amp;amp;p_id"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; if not missing(expdose) then call symput(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"headerdose"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,trim(expdose));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; else if not missing(exdstxt) then call symput(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"headerdose"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,trim(exdstxt)); &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; else call symput(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"headerdose"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;, NA);&amp;nbsp; ===&amp;gt; does not work. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;headerdose; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;getting message &lt;/FONT&gt;&lt;EM&gt;WARNING: Apparent symbolic reference HEADERDOSE not resolved.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2020 15:03:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-resolve-to-blank/m-p/694267#M211719</guid>
      <dc:creator>NJGIRL</dc:creator>
      <dc:date>2020-10-26T15:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: Macro -- resolve to blank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-resolve-to-blank/m-p/694268#M211720</link>
      <description>Unless NA (R programming?) is a variable that has a missing variable that isn't how you specify missing in SAS. &lt;BR /&gt;&lt;BR /&gt;else call symput("headerdose", ""); &lt;BR /&gt;&lt;BR /&gt;I would also strongly recommend you use call symputX() which has some extra features that help, like automatically trimming trailing spaces and allows you to specify if the macro variable is local or global.</description>
      <pubDate>Mon, 26 Oct 2020 15:06:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-resolve-to-blank/m-p/694268#M211720</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-10-26T15:06:47Z</dc:date>
    </item>
    <item>
      <title>Re: Macro -- resolve to blank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-resolve-to-blank/m-p/694270#M211721</link>
      <description>&lt;P&gt;Because your current code does not have a RUN statement to end the data step the %PUT is trying to reference the macro variable while the data step is being compiled, before it has had a chance to run.&amp;nbsp; Also if no observations match your WHERE clause then the data step will stop when it runs the SET statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Set the default value before the data step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let headerdose=No such subject;
data set_header2;
  set ex;
  where subject = "&amp;amp;p_id";
  if not missing(expdose) then call symputx("headerdose",expdose);
  else if not missing(exdstxt) then call symputx("headerdose",exdstxt);
  else call symput("headerdose", trimn(' '));  
run;
%put Headerdose = |&amp;amp;headerdose|;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Oct 2020 15:17:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-resolve-to-blank/m-p/694270#M211721</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-10-26T15:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: Macro -- resolve to blank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-resolve-to-blank/m-p/694276#M211724</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately, I am still getting the same error if expdose or exdstxt are missing (btw, they are character variables)&lt;/P&gt;
&lt;P&gt;data set_header2;&lt;/P&gt;
&lt;P&gt;set ex;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; where subject = &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"&amp;amp;p_id"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; if not missing(expdose) then call symput(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"headerdose"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,trim(expdose));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; else if not missing(exdstxt) then call symput(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"headerdose"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,trim(exdstxt)); &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; else call symput(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"headerdose"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;, &lt;/FONT&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;STRONG&gt;&lt;FONT size="3" color="#800080"&gt;"" &lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT size="3"&gt;); &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;LOG:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;WARNING: Apparent symbolic reference HEADERDOSE not resolved.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;let me know if you have any other ideas. thanks! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2020 15:50:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-resolve-to-blank/m-p/694276#M211724</guid>
      <dc:creator>NJGIRL</dc:creator>
      <dc:date>2020-10-26T15:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: Macro -- resolve to blank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-resolve-to-blank/m-p/694289#M211729</link>
      <description>&lt;P&gt;Tom, I am no longer getting an error in the log.&lt;/P&gt;
&lt;P&gt;your code works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; headerdose = --not avail;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data set_header2;&lt;/P&gt;
&lt;P&gt;set ex;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#008000"&gt;* where subject = "&amp;amp;p_id";&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; if subject = &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"&amp;amp;p_id"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; if not missing(expdose) then call symput(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"headerdose"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,trim(expdose));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; else if not missing(exdstxt) then call symput(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"headerdose"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,trim(exdstxt)); &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; else call symput(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"headerdose"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;, trimn(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;' '&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; )); &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;headerdose; run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good point regarding the 'where' clause... I replaced it with&amp;nbsp;an 'if' statement.&lt;/P&gt;
&lt;P&gt;Thanks. this save me significant research time (which do not have today:)&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, 26 Oct 2020 16:20:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-resolve-to-blank/m-p/694289#M211729</guid>
      <dc:creator>NJGIRL</dc:creator>
      <dc:date>2020-10-26T16:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: Macro -- resolve to blank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-resolve-to-blank/m-p/694311#M211733</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/144583"&gt;@NJGIRL&lt;/a&gt;&amp;nbsp; It appears the question has been answered. Requesting you to please mark &lt;STRONG&gt;your chosen&lt;/STRONG&gt; answer and close the thread. Thank you in advance. Have a nice day!&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2020 17:56:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-resolve-to-blank/m-p/694311#M211733</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-10-26T17:56:22Z</dc:date>
    </item>
  </channel>
</rss>

