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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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