You said “gender” which usually has two values. Your question was stated so as to make it hard to know you didn’t mean “gender,” but MD_Diag1.” This variable apparently has many many possible distinct values, some millions actually. However, you did say that your output has “male” for a value, and that does sound like “gender,” not MD_Diag1.
If you leave “ID” out of the table request AND leave “gender” out of the table request, you should not see “male” or get a case-by-case result, as you did. Thus your problem becomes too many distinct values of MD_Diag1. Even if SAS (or SPSS) COULD print them, you could not scan with your eye millions of values for MD_Diag1.
If you print ones with counts of over 1000, that would be interesting in terms of getting at the most common diagnoses. However, you said your goal was to combine diagnoses, not find out the most common ones. My guess is that if your MD_Diag1 is, say, a ten-digit code, and you have millions of different ones, the first three digits would be a major grouping, then the next three digits would be a finer grouping within the first group, and so on. Someone who understands diagnoses would need to suggest a rule for grouping.