<?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 add a condition checking statement in stored process in Developers</title>
    <link>https://communities.sas.com/t5/Developers/How-to-add-a-condition-checking-statement-in-stored-process/m-p/255796#M4903</link>
    <description>&lt;P&gt;Your symexist syntax is not valid. Is there any particular reason why you decided to create a table in the PROC SQL step and&amp;nbsp;use %SYMEXIST instead of the code I suggested?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To answer your question from before, the macro invocation/execution should be in your code where it makes most sense to evaluate the condition.&amp;nbsp; Usually, though, it's going to be somewhere towards&amp;nbsp;the end after you've done the prerequisite processing.&lt;/P&gt;</description>
    <pubDate>Thu, 10 Mar 2016 14:43:57 GMT</pubDate>
    <dc:creator>Timmy2383</dc:creator>
    <dc:date>2016-03-10T14:43:57Z</dc:date>
    <item>
      <title>How to add a condition checking statement in stored process</title>
      <link>https://communities.sas.com/t5/Developers/How-to-add-a-condition-checking-statement-in-stored-process/m-p/255427#M4895</link>
      <description>&lt;P&gt;Im doing stored process at the moment. I have sucessfully made it and generate a report. However, what if i want to add a condition checking statement to show "no data from users side" when there is no data to generate the report rather than SAS default error? any help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im using SAS EG&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2016 03:12:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/How-to-add-a-condition-checking-statement-in-stored-process/m-p/255427#M4895</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2016-03-09T03:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a condition checking statement in stored process</title>
      <link>https://communities.sas.com/t5/Developers/How-to-add-a-condition-checking-statement-in-stored-process/m-p/255435#M4896</link>
      <description>Could do something simple like create a macro within the code that auto-executes. Inside macro use a proc sql step to "count(*) into: obs_count from &amp;lt;your dataset&amp;gt;". Then use macro code to do a conditional statement "%if &amp;amp;obs_count &amp;gt;= 0 %then %do; &amp;lt;report code&amp;gt; %end;" then add alternate condition of no obs/records "%else %do; &amp;lt;print a message&amp;gt; %end;".&lt;BR /&gt;&lt;BR /&gt;Sorry, doing this from phone.</description>
      <pubDate>Wed, 09 Mar 2016 04:05:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/How-to-add-a-condition-checking-statement-in-stored-process/m-p/255435#M4896</guid>
      <dc:creator>Timmy2383</dc:creator>
      <dc:date>2016-03-09T04:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a condition checking statement in stored process</title>
      <link>https://communities.sas.com/t5/Developers/How-to-add-a-condition-checking-statement-in-stored-process/m-p/255451#M4897</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=WORK.JOIN2BCAE obs='No.' label;

var X_BCAE_NAME X_BCAE_POSITION X_BCAE_INCOME X_BCAE_CARLOAN X_BCAE_MORTGAGE X_BCAE_CASHFLOW newsum;
label X_BCAE_NAME = 'Name'
X_BCAE_POSITION = 'Position'
X_BCAE_INCOME = 'Income'
X_BCAE_CARLOAN = 'Car Loan Installment'
X_BCAE_MORTGAGE = 'Mortgage'
X_BCAE_CASHFLOW = 'Cash Flow'
newsum = 'Maximum New Loan';
sum X_BCAE_INCOME X_BCAE_CARLOAN X_BCAE_MORTGAGE X_BCAE_CASHFLOW newsum;
RUN
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have included my code....can you guide me mroe on how to do a checking to see if the WORK.JOIN2BCAE IS null or not...if null, then print 'No data found man'. Possible?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2016 07:26:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/How-to-add-a-condition-checking-statement-in-stored-process/m-p/255451#M4897</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2016-03-09T07:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a condition checking statement in stored process</title>
      <link>https://communities.sas.com/t5/Developers/How-to-add-a-condition-checking-statement-in-stored-process/m-p/255475#M4898</link>
      <description>&lt;P&gt;I have made a very simple SQL to count observation. What i wanna do is if its 0, then PROC PRINT data=work.nodata&lt;BR /&gt;ELSE PROC PRINT data=work.final&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is it possible?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2016 09:28:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/How-to-add-a-condition-checking-statement-in-stored-process/m-p/255475#M4898</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2016-03-09T09:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a condition checking statement in stored process</title>
      <link>https://communities.sas.com/t5/Developers/How-to-add-a-condition-checking-statement-in-stored-process/m-p/255533#M4900</link>
      <description>&lt;P&gt;There are multiple ways to do this, of course, but based on what you've provided I think it might look something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO CheckIt;

PROC SQL NOPRINT;
	SELECT COUNT(*) INTO: OBS_COUNT
	FROM WORK.JOIN2BCAE;
QUIT;

%IF &amp;amp;OBS_COUNT. &amp;gt; 0 %THEN %DO;

	proc print data=WORK.FINAL obs='No.' label;

	var X_BCAE_NAME X_BCAE_POSITION X_BCAE_INCOME X_BCAE_CARLOAN X_BCAE_MORTGAGE X_BCAE_CASHFLOW newsum;
	label X_BCAE_NAME = 'Name'
	X_BCAE_POSITION = 'Position'
	X_BCAE_INCOME = 'Income'
	X_BCAE_CARLOAN = 'Car Loan Installment'
	X_BCAE_MORTGAGE = 'Mortgage'
	X_BCAE_CASHFLOW = 'Cash Flow'
	newsum = 'Maximum New Loan';
	sum X_BCAE_INCOME X_BCAE_CARLOAN X_BCAE_MORTGAGE X_BCAE_CASHFLOW newsum;
	RUN
	;

%END;

%ELSE %DO;

	PROC PRINT DATA=WORK.NODATA;
	RUN;

%END;

%MEND;

%CheckIt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Or if your PROC PRINT statements would be the same for "FINAL" or "NODATA" then perhaps you could just make the dataset name dynamic, like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO CheckIt;

PROC SQL NOPRINT;
	SELECT COUNT(*) INTO: OBS_COUNT
	FROM WORK.JOIN2BCAE;
QUIT;

%IF &amp;amp;OBS_COUNT. &amp;gt; 0 %THEN %LET DATASET=FINAL;
	%ELSE %LET DATASET=NODATA;

	proc print data=WORK.&amp;amp;DATASET. obs='No.' label;

	var X_BCAE_NAME X_BCAE_POSITION X_BCAE_INCOME X_BCAE_CARLOAN X_BCAE_MORTGAGE X_BCAE_CASHFLOW newsum;
	label X_BCAE_NAME = 'Name'
	X_BCAE_POSITION = 'Position'
	X_BCAE_INCOME = 'Income'
	X_BCAE_CARLOAN = 'Car Loan Installment'
	X_BCAE_MORTGAGE = 'Mortgage'
	X_BCAE_CASHFLOW = 'Cash Flow'
	newsum = 'Maximum New Loan';
	sum X_BCAE_INCOME X_BCAE_CARLOAN X_BCAE_MORTGAGE X_BCAE_CASHFLOW newsum;
	RUN
	;

%MEND;&lt;BR /&gt;&lt;BR /&gt;%CheckIt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2016 14:33:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/How-to-add-a-condition-checking-statement-in-stored-process/m-p/255533#M4900</guid>
      <dc:creator>Timmy2383</dc:creator>
      <dc:date>2016-03-09T14:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a condition checking statement in stored process</title>
      <link>https://communities.sas.com/t5/Developers/How-to-add-a-condition-checking-statement-in-stored-process/m-p/255734#M4901</link>
      <description>&lt;P&gt;what if i have other PROC statement and datastep before PROC SQL nodata?&lt;/P&gt;&lt;P&gt;the %MACRO should remain there or move to the beginning of the .sas file?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2016 06:27:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/How-to-add-a-condition-checking-statement-in-stored-process/m-p/255734#M4901</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2016-03-10T06:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a condition checking statement in stored process</title>
      <link>https://communities.sas.com/t5/Developers/How-to-add-a-condition-checking-statement-in-stored-process/m-p/255739#M4902</link>
      <description>&lt;P&gt;Im getting this error when doing this code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO CheckIt;
proc sql;
create table countv2 as
select COUNT(CASE_RK) as n 'number'
from WORK.JOIN2BCAE;
quit;

%IF %SYMEXIST n=0 %then %do;

data testdo;
set WORK.JOIN2BCAE;
/*%if countv2.n =0 %then %do;*/
proc print data=nodata;
run;
%END;
%ELSE %DO;
proc print data=WORK.JOIN2BCAE obs='No.' label;
title 'Alfred Employee Bank Commitment/Financial Status';
var X_BCAE_NAME X_BCAE_POSITION X_BCAE_INCOME X_BCAE_CARLOAN X_BCAE_MORTGAGE X_BCAE_CASHFLOW newsum;
label X_BCAE_NAME = 'Name'
X_BCAE_POSITION = 'Position'
X_BCAE_INCOME = 'Income'
X_BCAE_CARLOAN = 'Car Loan Installment'
X_BCAE_MORTGAGE = 'Mortgage'
X_BCAE_CASHFLOW = 'Cash Flow'
newsum = 'Maximum New Loan';
sum X_BCAE_INCOME X_BCAE_CARLOAN X_BCAE_MORTGAGE X_BCAE_CASHFLOW newsum;
RUN;
%END;
%MEND;
%CheckIt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;ERROR: Expected open parenthesis after macro function name not found.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000" size="3" face="Courier New"&gt;Any advice?&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2016 08:29:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/How-to-add-a-condition-checking-statement-in-stored-process/m-p/255739#M4902</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2016-03-10T08:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a condition checking statement in stored process</title>
      <link>https://communities.sas.com/t5/Developers/How-to-add-a-condition-checking-statement-in-stored-process/m-p/255796#M4903</link>
      <description>&lt;P&gt;Your symexist syntax is not valid. Is there any particular reason why you decided to create a table in the PROC SQL step and&amp;nbsp;use %SYMEXIST instead of the code I suggested?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To answer your question from before, the macro invocation/execution should be in your code where it makes most sense to evaluate the condition.&amp;nbsp; Usually, though, it's going to be somewhere towards&amp;nbsp;the end after you've done the prerequisite processing.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2016 14:43:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/How-to-add-a-condition-checking-statement-in-stored-process/m-p/255796#M4903</guid>
      <dc:creator>Timmy2383</dc:creator>
      <dc:date>2016-03-10T14:43:57Z</dc:date>
    </item>
  </channel>
</rss>

