BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Swapnil_21
Obsidian | Level 7

Hi,

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.  Below is the sample data. 

Sr NoLogic
1If rate=10 and principal_amt=100000 then emi=5000
2If rate=9 and principal_amt=100000 then emi=4800
3If income>1000000 then risk=10
4If income<20000 then risk=80
5if category='New Customer' then do; rate=10; risk=20; end;

 

My Logic variable can be upto 1000 character variable. Now, how do I execute below code .

 

Data want;

set source;

If rate=10 and principal_amt=100000 then emi=5000;
If rate=9 and principal_amt=100000 then emi=4800;
If income>1000000 then risk=10;
If income<20000 then risk=80;
if category='New Customer' then do; rate=10; risk=20; end;

run;

 

 

Any help is really appreciated

1 ACCEPTED SOLUTION

Accepted Solutions
r_behata
Barite | Level 11
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>1000000 then risk=10
4 If income<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;

View solution in original post

1 REPLY 1
r_behata
Barite | Level 11
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>1000000 then risk=10
4 If income<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;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 416 views
  • 2 likes
  • 2 in conversation