tweaked2005
Technical User
I reviewed other post, and still can't seem to come up with a working solution.
I have a dataset similar to below:
id category
1 Fever
1 Headache
1 Nausea
1 Fever
2 Nausea
2 Accident
3 Fever
4 Accident
I want to create a new variable: "conditions" that has a concatenated list of categories by id. So for example, for id = 1, conditions = "FeverHeadacheNauseaFever"
Here is the code I'm using, but I'm not getting the right results:
Any help is greatly appreciated. Thanks!
I have a dataset similar to below:
id category
1 Fever
1 Headache
1 Nausea
1 Fever
2 Nausea
2 Accident
3 Fever
4 Accident
I want to create a new variable: "conditions" that has a concatenated list of categories by id. So for example, for id = 1, conditions = "FeverHeadacheNauseaFever"
Here is the code I'm using, but I'm not getting the right results:
Code:
data new; set old;
by id;
retain id conditions;
if first.id then conditions = '';
conditions = compress(conditions||category);
if last.id then output;
Any help is greatly appreciated. Thanks!