Hi all,
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);
array T(&mm);
array var(&mm);
do j = 1 by 1 until (last.id);
set data1;
by id;
T(j) = Time;
var(j) = score;
if var(j) = 20 then HIGH = 1; else HIGH=0;
end;
Thanks for your help!
-Katie
I think WHICHN will be helpful.
has1 = whichN(1,of T1-T100);
if has1 is greater than 1 then the range contains a least 1 variable with the target.
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.
Thanks!
-Katie
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.