Dear all, I have a dataset as shown below. ID is the subject ID and each of the variables Var1 and Var2 are measured every minute and can both have missing values. Dataset HAVE: ID Minutes Var1 Var2 A 1 -3.2 -5.1 A 2 . -3.6 A 3 . -1.1 A 4 5.2 -4.9 B 1 3.2 1.2 B 2 4.5 1.2 B 3 3.1 4.2 C 1 . 1.9 C 2 . -2.2 C 3 2.1 -3.1 I would like to count the number of times each ID has a value of Var1 and Var2 below (e.g.) zero. This I would like to output as a new dataset showing for each ID, the period of time (one entry is one minute) each of the two variables had a value below zero, and the percentage/ratio of values below zero to the total number of entries (excluding missing values), e.g. like: Dataset WANT: ID Var1_minutes_below Var2_minutes_below Var1_perc_below Var2_perc_below A 2 4 0.5 1 B 0 0 0 0 C 0 2 0 0.66 So far, I've been using SAS only for simple data management/statistics and this task I can't solve. Have tried reading a lot of posts solving similar problems using SQL/arrays, but I only have experience in the data step. I hope someone can help me with this? Kind regards, Alexander
... View more