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

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

 


 

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

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;

 

View solution in original post

3 REPLIES 3
Astounding
PROC Star

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.

novinosrin
Tourmaline | Level 20

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;

 

JayCompany
Calcite | Level 5
You sir, are the man!

sas-innovate-2024.png

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.

 

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.

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
  • 3 replies
  • 23663 views
  • 0 likes
  • 3 in conversation