Help me on this below scenario.
output requirements
1)flag variable- Flag on Countries IND and CHN.
If country IND then for first occurrence its should flag as 1 and if same data available in next occurrence that should flag it as 0 .
If same data chain got dis continued then again if we find IND in country column again it flags first data occurrence as 1 and remain 0.
Similarly
If country CHN then for first occurrence its should flag as 0 , if same data available in next occurrence that should flag it as 0 and only flag 1 for last occurrence of CHN before dis continue the same data .
If same data chain got dis continued then again if we find CHN in country column again it flags first data occurrence as 0 and next occurrence 1 .
2)Count variable- cumulative count .
data
Country
IND
IND
ENG
CHN
CHN
CHN
IND
IND
IND
USA
PAK
CHN
CHN
Expected output
count Country FLAG
1 IND 1
1 IND 0
2 ENG 0
3 CHN 0
3 CHN 0
3 CHN 1
4 IND 1
4 IND 0
4 IND 0
5 USA 0
6 PAK 0
7 CHN 0
7 CHN 1