<?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: How to exit if values in one variable is empty. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-exit-if-values-in-one-variable-is-empty/m-p/610347#M177726</link>
    <description>&lt;P&gt;thank you both for your reply. It worked!&lt;/P&gt;</description>
    <pubDate>Sun, 08 Dec 2019 23:08:38 GMT</pubDate>
    <dc:creator>SASMom2</dc:creator>
    <dc:date>2019-12-08T23:08:38Z</dc:date>
    <item>
      <title>How to exit if values in one variable is empty.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-exit-if-values-in-one-variable-is-empty/m-p/610311#M177712</link>
      <description>&lt;P&gt;I have a dataset that has two variables. The first columns has string variable called savings and another column has dollar amount of savings. There are three types of savings. So, basically, there are three rows and two columns. I use this table to create an excel file using ODS tagset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not want to create an excel file if there was no dollar amount in&amp;nbsp;ALL three savings I second column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Savings&lt;/TD&gt;&lt;TD&gt;Saving_Amount&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABC&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;DEF&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;GHI&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I program this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Dec 2019 18:49:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-exit-if-values-in-one-variable-is-empty/m-p/610311#M177712</guid>
      <dc:creator>SASMom2</dc:creator>
      <dc:date>2019-12-08T18:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to exit if values in one variable is empty.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-exit-if-values-in-one-variable-is-empty/m-p/610315#M177713</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/283628"&gt;@SASMom2&lt;/a&gt;&amp;nbsp; &amp;nbsp;You could use a conditional macro IF THEN statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select nmiss(Saving_Amount) ne count(*) into :check trimmed
from have;
quit;

%put &amp;amp;=check;

%if  &amp;amp;check %then %put creat excel file;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I hope you get the idea&lt;/P&gt;</description>
      <pubDate>Sun, 08 Dec 2019 19:03:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-exit-if-values-in-one-variable-is-empty/m-p/610315#M177713</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-12-08T19:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to exit if values in one variable is empty.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-exit-if-values-in-one-variable-is-empty/m-p/610316#M177714</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/283628"&gt;@SASMom2&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use a macro to run your code conditionally:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mydata;
	input Savings $	Saving_Amount;
	cards;
ABC .
DEF .
GHI .
;
run;


%macro _savings ();
	proc sql noprint;
		select count(*) into:mis_amount from mydata where Saving_Amount=.;
	quit;
	%if &amp;amp;mis_amount = 3 %then %do;
		proc print;/*&amp;lt;ODS TAGSETS statement&amp;gt;*/
	%end;
%mend;

%_savings
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 08 Dec 2019 19:06:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-exit-if-values-in-one-variable-is-empty/m-p/610316#M177714</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-12-08T19:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to exit if values in one variable is empty.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-exit-if-values-in-one-variable-is-empty/m-p/610330#M177716</link>
      <description>&lt;P&gt;Thank you for your reply. I think I am almost there except I want to say below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="token macrobound"&gt;%macro&lt;/SPAN&gt; _savings &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;sql&lt;/SPAN&gt; noprint&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;count&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;into&lt;/SPAN&gt;:mis_amount &lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt; mydata &lt;SPAN class="token statement"&gt;where&lt;/SPAN&gt; Saving_Amount&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;quit&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token macrostatement"&gt;%if&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;mis_amount &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&amp;nbsp;&lt;STRONG&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN class="token macrostatement"&gt;%then&lt;/SPAN&gt; &lt;SPAN class="token macrostatement"&gt;%do&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;got to the end of the code and exit.&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="token macrostatement"&gt;%end&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token macrobound"&gt;%mend&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token macroname"&gt;%_savings&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Dec 2019 20:04:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-exit-if-values-in-one-variable-is-empty/m-p/610330#M177716</guid>
      <dc:creator>SASMom2</dc:creator>
      <dc:date>2019-12-08T20:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to exit if values in one variable is empty.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-exit-if-values-in-one-variable-is-empty/m-p/610347#M177726</link>
      <description>&lt;P&gt;thank you both for your reply. It worked!&lt;/P&gt;</description>
      <pubDate>Sun, 08 Dec 2019 23:08:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-exit-if-values-in-one-variable-is-empty/m-p/610347#M177726</guid>
      <dc:creator>SASMom2</dc:creator>
      <dc:date>2019-12-08T23:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to exit if values in one variable is empty.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-exit-if-values-in-one-variable-is-empty/m-p/610428#M177763</link>
      <description>&lt;P&gt;Another possibility is to skip the macro stuff, and write to a temporary file instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename tempsas temp;
set have;
  where saving_amount is not null;
  file tempsas:
  put 'Proc Print data=have;run;';
  stop;
run;

%include tempsas;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That way, if there are no non-missing values, nothing will be written to your temporary SAS file, and nothing will be executed with the %INCLUDE statement.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2019 10:04:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-exit-if-values-in-one-variable-is-empty/m-p/610428#M177763</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2019-12-09T10:04:15Z</dc:date>
    </item>
  </channel>
</rss>

