BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have a dataset with two variables and three observation as following.

Formula($200.) Value(Best20.2)
netpv(0.1, 1,0, 1000)
sin(45)
netpv(0.1,1,0, netpv(0.1,1,0,2000)

How to calculate formula variable and update the result to value variable. Thanks all master-hand first!
3 REPLIES 3
Flip
Fluorite | Level 6
is this what you mean?

data _null_;
set xxx end = eof;
if _n_ = 1 then
call execute('data new; set xxx;');
call execute('if formula = "' || formula ||'" then value = ' ||formula || ';');
if eof then call execute('run;');
run;
deleted_user
Not applicable
You are my God, thank you very much!
data_null__
Jade | Level 19
This will be slow and it doesn't handle nested functions.

[pre]
data results;
input formula $40.;
value = input(resolve(cats('%sysfunc(',formula,')')),f8.);
cards;
netpv(0.1, 1,0, 1000)
sin(45)
netpv(0.1,1,0,2000)
;;;;
run;
proc print;
run;
[/pre]

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
  • 3 replies
  • 782 views
  • 0 likes
  • 3 in conversation