I have a large dataset with customer purchase data. I would like to create dummy variables for each combination of purchase order (1st purchase, 2nd purchase, etc.) and product category.
Sample table:
Note that several categories can be in the same purchase.
Sample output:
Apologies for using images, stack overflow doesn't allow me to paste tables 'cause I'm too new :)
Thank you in advance!
I tried doing all this manually but it is very arduous and purchase order will increase over time.


This is a really bad data structure, but if you want to get that, one way is below