|
Haiyi -
If you load your medication and severity information into arrays,
all you need to do is loop though the medication array looking for "1".
If you find one, increment a counter (for the number of times
medication was taken) and write out the severity value for that same
array index.
For example, try the following code:
data meds(keep=id taken sev);
infile cards missover;
input id tmed1-tmed6 tsev1-tsev6;
array tmed(6);
array tsev(6);
taken = 0;
do i = 1 to 6;
if tmed(i) then
do;
taken + 1;
sev = tsev(i);
output;
end;
end;
cards;
01 0 0 0 1 1 1 3 4 5 7 6 5
02 0 1 1 1 1 1 9 8 4 5 3 4
03 0 0 1 1 1 1 6 5 3 4 2 3
04 0 0 0 0 1 1 9 3 4 6 7 5
;
run;
The results are:
16:30 Tuesday, April 15, 1997 2
OBS ID TAKEN SEV
1 1 1 7
2 1 2 6
3 1 3 5
4 2 1 8
5 2 2 4
6 2 3 5
7 2 4 3
8 2 5 4
9 3 1 3
10 3 2 4
11 3 3 2
12 3 4 3
13 4 1 7
14 4 2 5
Now, you could do your analysis on the variables TAKEN and SEVERITY.
Hope this helps-
Pete Lund
WA State Office of Financial Management
peter.lund@ofm.wa.gov
----------
From: Haiyi Xie[SMTP:Haiyi.Xie@DARTMOUTH.EDU]
Sent: Wednesday, April 16, 1997 7:37 AM
To: Multiple recipients of list SAS-L
Subject: simple data step quesition
Suppose I have 4 subjects (each subject was measured weekly for 6
times), and
two variables. The first variable is "taking medicine or not" (1 =
take
medicine, 0 = not yet take medicine). The second variable is "severity
of
mental health symptom" (1 = not severe at all, 10 = very severe).
01 0 0 0 1 1 1 3 4 5 7 6 5
02 0 1 1 1 1 1 9 8 4 5 3 4
03 0 0 1 1 1 1 6 5 3 4 2 3
04 0 0 0 0 1 1 9 3 4 6 7 5
I wanted to compute means and standard deviations of "severity" score
when
people took medicine at the first time, the second time and so forth.
I other
words, I need to line up subjects in terms of the first time they took
medicine, then compute some descriptive statistics for variable
"severity".
Can somebody point me out how to do it in SAS data step? Thank you
very much.
Haiyi
|