Help using Base SAS procedures

Subratrion the obseravtions in one variable

Reply
Regular Contributor
Posts: 229

Subratrion the obseravtions in one variable

Hi
i have a data set

data x;
input sal;
cards
10
9
8
7
6
run;
i want the output like this id should substract form the first obs-second obs

the output shud be like this

sal;
10
1
1
1
run;
Super User
Posts: 5,437

Re: Subratrion the obseravtions in one variable

You could use the lag() function or the retain statement to make calculations between different observations.

/Linus
Data never sleeps
Ask a Question
Discussion stats
  • 1 reply
  • 88 views
  • 0 likes
  • 2 in conversation