Sorting data with multiple entries by participant ID

I am working with a dataset with a 24hr dietary recall. Each participant has multiple items of food for which they answered a yes/no question if it was consumed at a fast food restaurant. I want to sort this data by participant ID so I can end up with a dichotomous variable for each participant (1 = consumed fast food in last 24 hours, 2 = did not consume fast food in last 25 hours). Does anyone know the syntax to do this so it is sorted by participant ID (even though each participant has multiple food entries?). I am open to using other software but would ideally do this in SPSS or SAS. Thank you!


TS Contributor
So you have 3 columns, ID, type of food, and response (yes/no)?

If you use the Aggregate function with Id as break variable, you can
create an additional variable which tells you whether there had been
at least 1 "yes" response for an Id. In the next step, you can delete all
but one row of each Id (first sort by Id, then select using the statement
"Id ne LAG Id").

With kind regards