3 weeks ago
Happy 4th of July to all of you!
This is a simple question that I used to be able to do, but can't, for the life of me, figure out. I have attached a document in WORD on how the data is displayed (it's wide longitudinal or multivariate form). I can easily transpose it to the long form.
This is what I want to do, but there has to be a simpler way. I can do this little bit now, but I will be getting more data with repeated scorings.
1. Attachment = wide form of data = the data I'm interested in is s1-s20. I am taking the difference between them at each level. I already did the proc mixed, etc. but how could I write the code (in #2) easier?
2. Here is what I need do:
How can I do this easier? I thank you for your time. Marysia.
3 weeks ago
Good idea to use arrays here (no need for macros). Indeed, this is a typical use case for arrays.
data want; set have; array s; /* handle existing variables s1, ..., s20 as array elements s, ..., s */ array d; /* create new variables d1, ..., d19 and handle them as array elem. d, etc. */ do i=1 to 19; d[i]=s[i+1]-s[i]; /* array indices allow to compute the differences in a loop */ end; drop i; /* index variable is no longer needed */ run;