Hi, I'm a SAS novice so sorry if this is obvious. I'm trying to find the first instance of a certain value for a variable. For example, this is some of my data: id grp mon v1 v2 1 1 0 0 86 1 1 1 0 86 1 1 2 0 23 1 1 3 0 23 1 1 4 0 23 2 3 0 86 86 2 3 1 86 16 2 3 2 86 16 2 3 3 16 20 2 3 4 16 20 3 2 0 0 86 3 2 1 0 86 3 2 2 0 86 3 2 3 0 16 3 2 4 0 20 4 3 0 1 86 4 3 1 3 28 4 3 2 2 28 4 3 3 2 28 4 3 4 2 24 5 3 0 2 86 5 3 1 3 16 5 3 2 4 24 5 3 3 4 24 5 3 4 3 16 The data set has the participants id, which group they were in, month data was collected, and two variables of interest, v1 and v2. For v1 and v2, I would like to be able to pull out the first value after 0 or 86. For example, for id 1, the value of v2 I am interested in is 23; for id 4 it is 28, etc. I thought a round about way to do it would might be: data check; set check; if v1=86 then miss=.; else if v1=0 then miss=.; else do; miss +1; output; end; run; Then I could filter for miss=1 and find my values of interest. The problem is that I do not know how to automatically repeat the code for each id. Any help would be appreciated! Thank you!
... View more