Hi Everyone,
I have a dataset where I am trying to solve for X and then put that X value in a new variable. Below is a sample, with the missing value being X.
data sample;
input A S P C B;
datalines;
200 100 200 50 .
;
run;
The equation is: A = (S + P) - (C + B).
In this example, B is the X we're solving for. We know that B = 50 in this case since it's a simple equation but the real dataset has thousands of rows and more complicated numbers unfortunately. Is there any way I can have SAS solve for B, and then put that value of B on a new variable?
Thank you so much!
Are you asking for SAS to convert the assignment statement.
A = (S + P) - (C + B);
Into an assignment statement with B as the target?
Why not just perform the re-write yourself?
* start :
A = (S + P) - (C + B);
* remove () ;
A = S + P - C - B;
* add B to both sides ;
A+B = S + P - C ;
* subtract A from both sides;
B = S + P - C - A;
If your real problem is more complex then perhaps you need PROC IML or PROC NLIN?
Are you asking for SAS to convert the assignment statement.
A = (S + P) - (C + B);
Into an assignment statement with B as the target?
Why not just perform the re-write yourself?
* start :
A = (S + P) - (C + B);
* remove () ;
A = S + P - C - B;
* add B to both sides ;
A+B = S + P - C ;
* subtract A from both sides;
B = S + P - C - A;
If your real problem is more complex then perhaps you need PROC IML or PROC NLIN?
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.