<?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: Deleting missing in sas macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Deleting-missing-in-sas-macro/m-p/755571#M238473</link>
    <description>&lt;P&gt;Please discard the idea of using macro-code as it seems pointless. Also note, that comparing a variable with . will only work without funny notes in the log, if the variable is numeric. If you want don't want to think about the type of a variable, use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if missing(variable) then delete;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 21 Jul 2021 06:41:49 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2021-07-21T06:41:49Z</dc:date>
    <item>
      <title>Deleting missing in sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-missing-in-sas-macro/m-p/755558#M238469</link>
      <description>&lt;P&gt;I know this is probably bread and butter stuff in macro.&amp;nbsp; I am trying to delete missing observations for ch_aic and ch_gluc in my dataset by calling a macro. I normally do this in an if-then delete statement (as below) but I want to implement it in a macro. Any help will be appreciated. I used&amp;nbsp;&lt;/P&gt;&lt;P&gt;data us; set me;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let Ch_aic = if &amp;amp;dep = . then delete;&lt;/P&gt;&lt;P&gt;%let Ch_gluc = if &amp;amp;dep = . then delete;&lt;BR /&gt;run;&lt;BR /&gt;This didn't run. What could be wrong with this code?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  data me;
  set you;
  Ch_aic = Postaic-preaic;
  Ch_gluc= Postgluc-Pregluc;
  run;

  data us;
  set me;
  if Ch_gluc = . then delete
  if  Ch_aic =. then delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 05:30:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-missing-in-sas-macro/m-p/755558#M238469</guid>
      <dc:creator>ChuksManuel</dc:creator>
      <dc:date>2021-07-21T05:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting missing in sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-missing-in-sas-macro/m-p/755570#M238472</link>
      <description>&lt;P&gt;What went wrong? you never used the macro variables. And the macro variable DEP doesn't appear to have a value assigned either.&amp;nbsp; Did you read the log? I might expect a message&lt;/P&gt;
&lt;PRE&gt;WARNING: Apparent symbolic reference DEP not resolved.
&lt;/PRE&gt;
&lt;P&gt;When you see that message it means you attempted to use a variable when it does not have a value assigned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this maybe?&lt;/P&gt;
&lt;PRE&gt;  data junk;
  input x y $;
  datalines;
  1  abc
  2  cdf
  .  pdq
  4  .
  ;

  %macro mydelete(var=);
  if missing(&amp;amp;var.) then delete;
  %mend;

  data junk2;
    set junk;
    %mydelete(var=x);
    %mydelete(var=y);
  run;
&lt;/PRE&gt;
&lt;P&gt;Doesn't save much code from an if/then.&lt;/P&gt;
&lt;P&gt;Note that I use the Missing function because it will detect missing character as well as numeric variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your &lt;STRONG&gt;real question&lt;/STRONG&gt; is to delete a record if any of a bunch of numeric variables is missing then a macro isn't needed.&lt;/P&gt;
&lt;PRE&gt;  data junk;
  input x1-x4  y $;
  datalines;
  1 11 111 1111 abc
  2 22 222 2222 cdf
  . 33 333 3333 pdq
  4  . 444 4444 lkj
  5  . .   .    kkk
  ;

 data junk2;
    set junk;
    if nmiss(of x1-x4) &amp;gt; 0 then delete;
 run;
&lt;/PRE&gt;
&lt;P&gt;NMISS counts the number of numeric values that are missing in a list. So if any of the X variables in the above example are missing then the result from the function is greater than 0 and the record is deleted. The "of x1-x4" is one of the short hand ways to create lists of variables so they don't all have to be typed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Character variables take more work depending on the possible content.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 06:44:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-missing-in-sas-macro/m-p/755570#M238472</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-07-21T06:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting missing in sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-missing-in-sas-macro/m-p/755571#M238473</link>
      <description>&lt;P&gt;Please discard the idea of using macro-code as it seems pointless. Also note, that comparing a variable with . will only work without funny notes in the log, if the variable is numeric. If you want don't want to think about the type of a variable, use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if missing(variable) then delete;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Jul 2021 06:41:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-missing-in-sas-macro/m-p/755571#M238473</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-07-21T06:41:49Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting missing in sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-missing-in-sas-macro/m-p/755573#M238475</link>
      <description>&lt;P&gt;I am learning macro hence the question. Thanks for the input.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 06:46:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-missing-in-sas-macro/m-p/755573#M238475</guid>
      <dc:creator>ChuksManuel</dc:creator>
      <dc:date>2021-07-21T06:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting missing in sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Deleting-missing-in-sas-macro/m-p/755574#M238476</link>
      <description>&lt;P&gt;Thanks. That's exactly what i wanted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 06:50:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Deleting-missing-in-sas-macro/m-p/755574#M238476</guid>
      <dc:creator>ChuksManuel</dc:creator>
      <dc:date>2021-07-21T06:50:03Z</dc:date>
    </item>
  </channel>
</rss>

