Hello everyone, I am working on stata 15.
I have a variable "diff6" that takes the value 1 in records that meet a condition. I need to mark the previous record, which in this case are patient MRIs. It is your previous resonance.
Thank you very much for the help !!
input str11 id float(date previous_date diff6)
"10017290" 19739 . .
"10017290" 20101 19739 .
"10017290" 20560 20191 .
"10017290" 22211 21455 .
"10017290" 22568 22211 .
"10017290" 22989 22568 .
"10017290" 23018 22989 .
"10017290" 23382 23018 .
"10019723" 17015 . .
"10019723" 21587 . .
"10019723" 22811 21587 .
"10032146" 21810 . .
"10032146" 22216 21810 .
"10047233" 19638 . .
"10047233" 21535 19638 .
"10047233" 22943 21535 .
"10052723" 21138 20682 .
"10071986" 20332 . .
"10071986" 20584 20332 .
"10071986" 20955 20950 .
"10071986" 21319 20955 .
"10071986" 21684 21319 .
"10071986" 22042 21684 .
"10071986" 22510 22042 .
"10071986" 22817 22510 .
"10071986" 23047 22817 .
"10103855" 16528 . .
"10103855" 16748 16528 .
"10103855" 17242 16748 .
"10103855" 18262 17242 .
"10103855" 19836 18262 .
"10103855" 20107 19836 .
"10103855" 21364 20959 .
"10103855" 21551 20959 .
"10103855" 21885 21551 1
"10103855" 22259 21885 .
"10103855" 22582 22259 .
"10103855" 23036 22582 .
"10124922" 22593 21692 .
"10124922" 22992 22593 .
"10125085" 22120 21264 .
"10125085" 22471 22120 .
"10125085" 22912 22471 .
"10125085" 23270 22912 .
"10144853" 18960 . .
"10144853" 19859 18960 .
"10144853" 20851 19859 .
"10144853" 22348 20851 .
"10231192" 21477 . .
"10251842" 21748 . .
"10251842" 22210 21748 .
"10251842" 22643 22210 .
"10251842" 22960 22643 .
"10268310" 20158 . .
"10268310" 20735 20158 .
"10268310" 21416 20735 .
"10268310" 22307 21843 .
"10268310" 22664 22307 .
"10268310" 23077 22664 .
"10289919" 17165 . .
"10289919" 17423 17165 .
"10289919" 17688 17423 .
"10289919" 19823 17688 .
"10289919" 20478 19823 .
"10289919" 21532 20851 .
"10289919" 21934 21532 .
"10289919" 22687 21934 .
"10309749" 20830 . .
"10309749" 21211 20830 .
"10309749" 22551 21211 .
"10329252" 22027 . .
"10329252" 22413 22027 .
"10329252" 22775 22413 .
"10329252" 23147 22775 .
"10380065" 18290 . .
"10380065" 19633 18290 .
"10380065" 21025 19633 .
"10380065" 21453 19633 .
"10380065" 21453 21025 .
"10380065" 21951 21453 .
"10380065" 22369 21951 .
"10380065" 22715 22369 .
"10380065" 23219 21453 .
"10380065" 23219 22715 .
"10398952" 21767 . .
"10398952" 22656 21767 .
"10398952" 23037 22656 .
"10442281" 22211 . .
"10442281" 23154 22211 .
"10482004" 17050 . .
"10482004" 22706 22113 .
"10488480" 21699 . .
"10488480" 22202 21699 .
"10488480" 22301 22202 .
"10488480" 22665 22301 .
"10551568" 21881 . 1
"10551568" 22239 21881 .
"10551568" 22600 22239 .
"10551568" 22995 22600 .
"10551568" 23395 22995 .
end
format %dD_m_CY date
format %dD_m_CY previous_date
Comment