I have ID, amount, date in my data sets, and each ID has a number of amount & date.
Now I want to have a sequence variable, that for each ID, the first date has sequence value 1, the second date has sequence value 2, etc. For those with has only 1 date, delete.
can anyone tell me how to do this? I sort by ID and date, and use first.ID and last.ID to loop?
another question is, after I have the sequence variable, I want to use regression (DV=amount, IV=sequence) to see the trend of the amount, positive or negative. I want to have a new data set with only ID and Beta (coefficients).
PROC REG DATA=with_sequence;
BY ID ;
MODEL amount= sequence ;
output out=b;
RUN;
Is this the right way to do it?
... View more