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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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