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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 1353 views
  • 0 likes
  • 3 in conversation