- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 09-19-2008 04:30 AM
(920 views)
i have ao datasets i want to minus the first observation by another
data x;
input id sal;
cards;
1 2
3 4
5 6
7 8
run;
i want like this id -sal by leaving the first observariopn 1-4,3-6,5-8 finally the output shd be like this.
data x;
input id sal;
cards;
1 2
3 4
5 6
7 8
run;
i want like this id -sal by leaving the first observariopn 1-4,3-6,5-8 finally the output shd be like this.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can use the lag function/
If i take your example it may look like this:
data b;
set x;
w=lag(id)-sal;
run;
If i take your example it may look like this:
data b;
set x;
w=lag(id)-sal;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
A DATA step and investigate using the LAG function to use variable values from a previous observation. Have a look at the SAS.COM support website and the SAS Language Guide discussion on the LAG function. Also, there are also technical papers from prior conferences available on the website.
Scott Barry
SBBWorks, Inc.
Scott Barry
SBBWorks, Inc.