<?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: Execute logic based on variable from table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Execute-logic-based-on-variable-from-table/m-p/604010#M175057</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data logic;
input Sr_No	Logic $2-100;
infile datalines4 truncover;
datalines4;
1 If rate=10 and principal_amt=100000 then emi=5000
2 If rate=9 and principal_amt=100000 then emi=4800
3 If income&amp;gt;1000000 then risk=10
4 If income&amp;lt;20000 then risk=80
5 if category='New Customer' then do; rate=10; risk=20; end;
;;;;
run;

data _null_;
	set logic end=eof;

	if _n_=1 then
		do;
			call execute('data want; set source;');
		end;


		call execute(' ' !! catx(' ',Logic,';') !! ' ');
	

	if eof then
		do;
			call execute('run;');
		end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 14 Nov 2019 02:50:18 GMT</pubDate>
    <dc:creator>r_behata</dc:creator>
    <dc:date>2019-11-14T02:50:18Z</dc:date>
    <item>
      <title>Execute logic based on variable from table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Execute-logic-based-on-variable-from-table/m-p/604002#M175054</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have master table called Have and in that table there is column called Logic. It has around 100 observations. All of those observations are actually the logic for data processing. How do I read data from that variable and execute it. I tried using call execute but somehow never got that correct.&amp;nbsp; Below is the sample data.&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Sr No&lt;/TD&gt;&lt;TD&gt;Logic&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;If rate=10 and principal_amt=100000 then emi=5000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;If rate=9 and principal_amt=100000 then emi=4800&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;If income&amp;gt;1000000 then risk=10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;If income&amp;lt;20000 then risk=80&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;if category='New Customer' then do; rate=10; risk=20; end;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Logic variable can be upto 1000 character variable. Now, how do I execute below code .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data want;&lt;/P&gt;&lt;P&gt;set source;&lt;/P&gt;&lt;P&gt;If rate=10 and principal_amt=100000 then emi=5000;&lt;BR /&gt;If rate=9 and principal_amt=100000 then emi=4800;&lt;BR /&gt;If income&amp;gt;1000000 then risk=10;&lt;BR /&gt;If income&amp;lt;20000 then risk=80;&lt;BR /&gt;if category='New Customer' then do; rate=10; risk=20; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is really appreciated&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 01:55:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Execute-logic-based-on-variable-from-table/m-p/604002#M175054</guid>
      <dc:creator>Swapnil_21</dc:creator>
      <dc:date>2019-11-14T01:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Execute logic based on variable from table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Execute-logic-based-on-variable-from-table/m-p/604010#M175057</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data logic;
input Sr_No	Logic $2-100;
infile datalines4 truncover;
datalines4;
1 If rate=10 and principal_amt=100000 then emi=5000
2 If rate=9 and principal_amt=100000 then emi=4800
3 If income&amp;gt;1000000 then risk=10
4 If income&amp;lt;20000 then risk=80
5 if category='New Customer' then do; rate=10; risk=20; end;
;;;;
run;

data _null_;
	set logic end=eof;

	if _n_=1 then
		do;
			call execute('data want; set source;');
		end;


		call execute(' ' !! catx(' ',Logic,';') !! ' ');
	

	if eof then
		do;
			call execute('run;');
		end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Nov 2019 02:50:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Execute-logic-based-on-variable-from-table/m-p/604010#M175057</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2019-11-14T02:50:18Z</dc:date>
    </item>
  </channel>
</rss>

