my data set has two variables ID and diagnosis. I am trying to assign row numbers in my dataset based on ID and diagnosis.
the code that I used was;
proc sort data = temp;
by ID diagnosis;
run;
proc rank data = temp out = temp1;
by id;
var diagnosis;
ranks = diag_rank;
run;
Its giving mr error: the variable diagnosis in list does not match the type
I know my diagnosis has both text and numric values. Is there a way to fix this. Thanks a lot.
If you are just looking for a unique row number, then the following should work.
If you need a conditional row number based on ID and diagnosis, then try:
If, on the other hand, there is some explicit order of ranking that you wish to impose on the DIAGNOSIS variable other than the sorted character values, then you could use a user-defined format to map each of the character values to a number, then use this format to create a row_number variable in a data step, like the following.