I am trying to compare cross values on different date columns.Flag column has two values : D and R. My conditions are when D-Flag comes after R-flag and DATE2 equals to DATE1 create column named False_Flag and append 1 else append 0 by ID.
Here is a example of my table :
At ID=1, DATE2 on first row equals to DATE1 on second column and D flag comes after R flag so I want to create new column named False_flag and append 1 for this situation. And same for ID =3,for other situations like ID = 5 append 0 for False_flag
ID DATE1 DATE2 FLAG
1 10JUN2021 17JUN2021 R
1 17JUN2021 25SEP2021 D
3 12MAR2018 25MAR2018 R
3 25MAR2018 14APR2018 D
3 14APR2018 23JUL2018 D
5 22OCT2020 15NOV2020 D
And here is What I want for output:
ID DATE1 DATE2 FLAG FALSE_FLAG
1 10JUN2021 17JUN2021 R 1
1 17JUN2021 25SEP2021 D 1
3 12MAR2018 25MAR2018 R 1
3 25MAR2018 14APR2018 D 1
3 14APR2018 23JUL2018 D 0
5 22OCT2020 15NOV2020 D 0
I am pretty new in SAS and How can I do that ?