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: 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 25. 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
  • 2 replies
  • 452 views
  • 0 likes
  • 2 in conversation