Selecting the first record for a particular variable based on a condition

#1
I have a data set with time series data for the respective account numbers. I'm trying to select the first record for an account number (and the corresponding month field) that meets a particular condition. I was trying to achieve this objective with a proc sort statement but I was still getting duplicate account number observations. Here is the SAS code I wrote in order to execute this objective:

proc sort data=master_a out=master_b nodupkey;
by descending acctnum descending month;
where TDR=1 (1 meaning yes);
run;

I want to see one single record for each account number which will have the first occurence where TDR=1 .

Any assistance would be greatly appreciated. Thanks.
 
#2
Try following your sort procedure with a second one, thus:

proc sort data=master_b nodupkey;
by acctnum;
run;

Note that your sort procedure will pick out the latest occurrence (assuming "month" is numeric) rather than the earliest.