Desktop productivity for business analysts and programmers

Subtract values of same variable?

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Subtract values of same variable?

Is there a way to subtract one value of a variable (column) from another value of the same variable?

For instance, I have a single column of numeric values:

1

2

3

4

5

and I want to subtract the first value in the column from the second (i.e. 2-1), the second value from the third, etc.


Accepted Solutions
Solution
‎04-10-2013 06:37 PM
Respected Advisor
Posts: 3,788

Re: Subtract values of same variable?

Look in the online documentation for the DIF function.

View solution in original post


All Replies
Solution
‎04-10-2013 06:37 PM
Respected Advisor
Posts: 3,788

Re: Subtract values of same variable?

Look in the online documentation for the DIF function.

Trusted Advisor
Posts: 1,137

Re: Subtract values of same variable?

Hi,

You can try something like this as suggested by data_null_

data have;

  input num;

  substract=dif(num);

datalines;

1

2

3

4

5

;

run;

Thanks,

Jagadish

Thanks,
Jag
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 1807 views
  • 4 likes
  • 3 in conversation