We have a question about how to sum horizontally in SAS. The data exists in SAS format, and we know the names of the variables. Our dataset contains several horizontal rows, each one representing a person. Each column represents one week and all the week-variables are numeric (the time period is from year 1999-2001, thus the total number of columns/weeks is 52*3 = 156). All observations contain one of the following values: “1” and “0”. We would really appreciate if anyone would like to help us with a SAS code enabling us to sum horizontally in a row (i.e. a time period for each person of the dataset) and thereby generating a variable, which counts the sum of week number 25 and 26 from the first week you meet the value “1”. Meaning that the code from the first time you meet “1” counts 25 and 26 weeks ahead and generates a variable, which contains the sum of those two weeks. An example is a “1” observation in week 12 in 1999, the new variable should only count 25 and 26 weeks ahead, and thereby only summing week 37 and 38 in 1999. The new variable (sum variable) can either take the value 0, 1 or 2 depending on whether the “1” value is present in zero, one week or both weeks (week 37 and 38). It doesn’t matter which values the weeks between week 1 and 25 contains (“0” or “1”). The first observed “1” has to be placed in a week in the period year 1999-2001, but the following observations (week number 25 and 26) are also allowed to be places outside the period (e.g. in year 2002), as long as the first observation is placed in a week between year 1999-2001. Thank you in advance. Best regards, Maria and Sissel
... View more