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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.