Hi,
I have one dataset with 2 columns. I would like to subtract the two columns and output this difference to a new SAS dataset. How would I go about doing this?
Original Table:
ID, A2017, B2018
Desired Table:
B2018 - A2017
why didn't you try the most basic? Not trying to find fault, but these kind of questions may not be appreciated by most solution contributors.
data your_wanted_output;
set your_given_input;
new_column_c = column_b - column_a;
keep new_column_c ;
run;
It's a little difficult knowing where to begin here. Let's start with assessing what you already have and what you already know.
When you say you have a data set, is it already a SAS data set?
Do you know how to create a new SAS data set?
Do you know how to bring in data from an existing SAS data set?
Do you know how to create a new variable?
Do you know how to assign that new variable the outcome of a subtraction?
The solution will look incredibly simple in retrospect. I'm just trying to determine how much of it you already understand, so the solution can focus on the rest of the question.
why didn't you try the most basic? Not trying to find fault, but these kind of questions may not be appreciated by most solution contributors.
data your_wanted_output;
set your_given_input;
new_column_c = column_b - column_a;
keep new_column_c ;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.