I have a SAS dataset where each row represent a contact to a doctor for some person ID. Each ID have a different number of contacts (ie. rows). My dataset looks as follows.
What I want to do is end up with a dataset, that looks like
That is for each unique ID I want to have a dataset, where I create columns for each contact number (NUMBER) and what that type of contact is (CONTACT_TYPE), and the columns should be named based on the number of contact. I also want the code to be automatically create columns based on the ID with the largest number of contacts (MAX) i.e. NUMBER&MAX should be my last column.
I have attempted to somehow convert the NUMBER into a macro-variable 'Name' and that then attempted to somehow
%let name = NUMBER
and then used this in a datastep to do something like
NUMBER&name. = CONTACT_TYPE
in a data step. However, this has not worked for me, and is most likely very inefficient I suspect.
Can someone point me in the right direction to solve this?
Thank you in advance for your time.
Regards Alexander