Help using Base SAS procedures

proc sql: How can I scan a table?

Reply
N/A
Posts: 0

proc sql: How can I scan a table?

Hi everyone!!

I'm a spanish student, and I need to scan a table in SAS, register by register, to make an update on every row (depending of several conditions that include variables in previous row)

For example, I want to modify the field Date2 in this example with de field Date of the previous field, if the previous row is the same ID:

Initially:

ID DATE DATE2
1 "25-Oct-2000" ""
1 "30-Oct-2001" ""
1 "25-Nov-2002" ""
2 "13-Jan-2000" ""
2 "15-Mar-2001" ""

Finally

ID DATE DATE2
1 "25-Oct-2000" ""
1 "30-Oct-2001" "25-Oct-2000"
1 "25-Nov-2002" "30-Oct-2001"
2 "13-Jan-2000" ""
2 "15-Mar-2001" "13-Jan-2000"

Thanks and sorry for my english (is very poor)!!!!!
N/A
Posts: 0

Re: proc sql: How can I scan a table?

Hi, not sure how to do it in Proc SQL, but in base SAS it can be done this way:

Data ;
Set ;
By Id;
DATE2=lag(DATE);
If first.ID then DATE2="";
Run;
N/A
Posts: 0

Re: proc sql: How can I scan a table?

Thanks!!

One doubt more: with your code, the last row in the final table is deleted. do you know why?
N/A
Posts: 0

Re: proc sql: How can I scan a table?

Fixed!!!

Other question. How can I define and work with a variable into a data segment?
Ask a Question
Discussion stats
  • 3 replies
  • 129 views
  • 0 likes
  • 1 in conversation