a********a 发帖数: 346 | 1 How can I transfer the data structure from one to two? Basically I want to
get the visit date difference for other visits to visit 0, and value
difference for other visits to visit 0. Thanks
data one;
input id visit date ddmmyy10. value;
format date ddmmyy10.;
datalines;
1 0 1/1/2010 0.5
2 0 3/1/2010 0.8
2 2 5/1/2010 1.5
2 4 7/1/2020 0.3
3 0 4/5/2010 1
3 2 6/5/2010 0.9
;
r | f********t 发帖数: 117 | 2 select *, a.visit as visit1, b.visit as visit2,
a.date as date_start, b.date as date_end, a.value as value1, b.value as
value 2
from (select * from one where visit = 0) a
left join one b on (a.id = b.id and b.vist > 0 )
Ii dont have sas, but idea is the same. list all first visit, and find all
other visits after the first visits for the id. and align them on the same
row. that is what left join is good for.
| a********a 发帖数: 346 | |
|