07-16-2013 01:12 PM
I am trying to create indicator variables, based on information in other variables in my table. I have a data set in wide format (which I created from long) that has subject data at many (up to 700) different timepoints. Basically, if ANY of those time points have a specific value, I'd like to create an indicator. For example, if any of T1-T100 = 1, then I want INDICATOR=1.
Can I have SAS specify a range of variable to check in my IF statement? I know I can us multiple "or" statements, but this is not practical, given the large number of time points.
Also, I considered writing it into my array when I converted from long to wide format, but this did not seem to work and I did not see documentation on this particular issue.
This is what I tried..
data wide (keep=id T1-T&mm var1-var&mm);
do j = 1 by 1 until (last.id);
T(j) = Time;
var(j) = score;
if var(j) = 20 then HIGH = 1; else HIGH=0;
Thanks for your help!
07-16-2013 02:29 PM
Thanks, data_null, this is helpful. It will return the ordered number of the first variable it hits, correct? So if my data row were to look like
T1 T2 T3 T4
8 9 10 7
has1 = whichN(9, of T1-T4)
would return has1=2
This could work, because then I would just need to add a line of code if has1 > 0 then has1=1.