BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mitrakos
Obsidian | Level 7

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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?

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

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?

mitrakos
Obsidian | Level 7
Oh god I was so caught up in trying to solve for x using the formula given to me I didn’t even think about rewriting it. I’m so dumb. Thank you so much!!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of 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
  • 2 replies
  • 496 views
  • 0 likes
  • 2 in conversation