Hello SAS users. I am completely fresh in the field of SAS programming. I have a rather large dataset, with 143 variables (one for each week of the year, for the years 2016-2018 week 39), named y_1601-y_1652, y_1701-y_1752, and y_1801-y_1839. In each of these weeks there is either a numeric code or a missing value. What I am interested in is counting the lengths of consecutive occurences of 111 and create a variable with this information. This in itself is easy enough, the tricky part is that I want to allow for a period of up to 4 weeks without 111 occuring, and still be counted as a part of the sequence of 111 occuring in a row. At the same time, if there are more than 4 consecutive weeks without 111 occuring, I want the number of consecutive occurences to be stored in a variable, if 111 starts occurring once more this information to be stored in another variable. Unfortunately, I am unable to give a sample of my data, however I think this example illustrates my point: Data have: input id y_1601 y_1602 y_1603 y_1604 y_1605 y_1606 y_1607 y_1608 y_1609 y_1610 y_1611 y_1612; datalines; 1 111 111 111 111 . . . . . . . . 2 23 . 111 111 111 . . . . . 111 111 3 52 111 111 111 111 87 87 111 111 111 111 111; Data want: input id y_1601 y_1602 y_1603 y_1604 y_1605 y_1606 y_1607 y_1608 y_1609 y_1610 y_1611 y_1612 seq1 seq2; datalines; 1 111 111 111 111 . . . . . . . . 4 . 2 23 . 111 111 111 . . . . . 111 111 3 2 3 52 111 111 111 111 87 87 111 111 111 111 111 11 .; Any help is greatly appreciated!
... View more