Hello there, I pratice SAS for several years, but I am not an expert at all especially when dealing with loops and double &. I think about the following problem for quite some time, and tried a lot of keyword research online, with no success. I want to solve this problem only in SAS, not in another software. Please consider the following table (it is my first post sorry if the format is not good): data have;
input ID Base Reach1 Reach3 Reach6 Reach10 Reach15 :BEST12.;
cards;
1 5 1 1 1 9 10
2 6 1 1 1 8 9
3 8 1 1 2 7 8
4 4 1 1 1 6 7
5 9 1 3 4 5 6
6 2 1 2 3 4 5
7 1 1 1 2 3 4
8 5 1 1 1 2 3
9 6 1 1 1 1 2
10 10 1 1 1 1 1
11 25 1 2 3 . .
12 2 1 1 2 . .
13 4 1 1 1 . .
14 6 . . . . .
;run; The core dataset are the two first columns, ID and Base. The important column is Base. The following columns Reachx are the ones I want to construct with SAS code. I want, considering the column Base, for each row and for a specific number (which can be another numeric variable), to find in the next rows the first time the number or a superior number occur, (value = that row number after the current row). Exemples For Reach1, how much row(s) I need to go down in the column Base to find a 1 or higher For Reach3, how much row(s) I need to go down in the column Base to find a 3 or higher For Reachx, how much row(s) I need to go down in the column Base to find a x or higher Plot twist: I have 800k rows I tried looking forward with lag in a reverse order table; there is probably something to do with a loop but it is not my level of expertise. I tried looking for proc expand, which solved some of my similar problems, but not this one. Can you help me ? Thank you for spending time to read and answer neebies questions, either or not you answer this one 🙂 Regards Shaf
... View more