t**********r 发帖数: 182 | 1 The data looks like this:
uniqueID, observedate, observer, growthrate,
11111111, 20020908, John, 0.22
11111111, 20021210, John, 0.21
22222222, 19980101, Peter, 0.33
22222222, 19980401, Peter, 0.33
33333333, 19950505, Smith, 0.34
.....
Question;
for each uniqueID, if the name of observer has changed, I need to add one
line of information after the last line to indicate that person has stopped
observing. The observedate is equal to the last date + 3 month.
For example,
11111111, 20020908, John, 0. | c*******o 发帖数: 8869 | 2 your example does not make sense. for unique ID 11111111, observer does not
change, who is always john. why do you need to add the new line?
【在 t**********r 的大作中提到】![](/moin_static193/solenoid/img/up.png) : The data looks like this: : uniqueID, observedate, observer, growthrate, : 11111111, 20020908, John, 0.22 : 11111111, 20021210, John, 0.21 : 22222222, 19980101, Peter, 0.33 : 22222222, 19980401, Peter, 0.33 : 33333333, 19950505, Smith, 0.34 : ..... : Question; : for each uniqueID, if the name of observer has changed, I need to add one
| C******t 发帖数: 72 | 3 Maybe this is what you want. Just be cautious that the variable type is
changed to character to accomodate "stop".
data origin;
input uniqueID $ observedate $ observer $ growthrate $;
datalines;
11111111 20020908 John 0.22
11111111 20021210 John 0.21
22222222 19980101 Peter 0.33
22222222 19980401 Peter 0.33
33333333 19950505 Smith 0.34
;
run;
data addstop;
set origin;
if last.uniqueID then do;
output;
growthrate='stop';
output;
end;
else output;
by uniqueID;
run; | t**********r 发帖数: 182 | 4 thanks. pls check baozi. |
|