<?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: TURN MACROVARIABLE FROM MISSING TO 0? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/TURN-MACROVARIABLE-FROM-MISSING-TO-0/m-p/787548#M251658</link>
    <description>&lt;P&gt;If you want to change the value use a %LET statement.&lt;/P&gt;
&lt;P&gt;If you want to change it conditionally then use a %IF/%THEN/%DO block.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro variables do not have a concept of missing.&amp;nbsp; They are just text strings.&lt;/P&gt;
&lt;P&gt;If by missing you mean not defined then use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if not %symexist(mvar) %then %do;
  %let mvar=0;
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If by missing you mean totally empty then use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if 0=%length(&amp;amp;mvar) %then %do;
  %let mvar=0;
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But you might want to instead update the code that is creating the macro variable to create it with zero for missing.&lt;/P&gt;
&lt;P&gt;So if you created macro variable MVAR from actual variable VAR then perhaps update the code to be more like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symputx('mvar',coallesce(var,0));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Dec 2021 20:10:51 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-12-28T20:10:51Z</dc:date>
    <item>
      <title>TURN MACROVARIABLE FROM MISSING TO 0?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/TURN-MACROVARIABLE-FROM-MISSING-TO-0/m-p/787544#M251656</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how can I turn a macrovariable currently having missing value to being zero?&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;&lt;P&gt;Your sincerely,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Simone&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Dec 2021 19:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/TURN-MACROVARIABLE-FROM-MISSING-TO-0/m-p/787544#M251656</guid>
      <dc:creator>SimoneStefano96</dc:creator>
      <dc:date>2021-12-28T19:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: TURN MACROVARIABLE FROM MISSING TO 0?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/TURN-MACROVARIABLE-FROM-MISSING-TO-0/m-p/787548#M251658</link>
      <description>&lt;P&gt;If you want to change the value use a %LET statement.&lt;/P&gt;
&lt;P&gt;If you want to change it conditionally then use a %IF/%THEN/%DO block.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro variables do not have a concept of missing.&amp;nbsp; They are just text strings.&lt;/P&gt;
&lt;P&gt;If by missing you mean not defined then use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if not %symexist(mvar) %then %do;
  %let mvar=0;
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If by missing you mean totally empty then use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if 0=%length(&amp;amp;mvar) %then %do;
  %let mvar=0;
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But you might want to instead update the code that is creating the macro variable to create it with zero for missing.&lt;/P&gt;
&lt;P&gt;So if you created macro variable MVAR from actual variable VAR then perhaps update the code to be more like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symputx('mvar',coallesce(var,0));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Dec 2021 20:10:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/TURN-MACROVARIABLE-FROM-MISSING-TO-0/m-p/787548#M251658</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-28T20:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: TURN MACROVARIABLE FROM MISSING TO 0?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/TURN-MACROVARIABLE-FROM-MISSING-TO-0/m-p/787551#M251660</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your answer. The&amp;nbsp;&lt;SPAN&gt;%IF/%THEN/%DO block was just what I was looking for.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Have a nice day,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Simone&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Dec 2021 20:12:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/TURN-MACROVARIABLE-FROM-MISSING-TO-0/m-p/787551#M251660</guid>
      <dc:creator>SimoneStefano96</dc:creator>
      <dc:date>2021-12-28T20:12:06Z</dc:date>
    </item>
  </channel>
</rss>

