In reply to Karolina.

In general, the SAS Support Communities are the best place to ask programming questions. To answer your question, put a WHERE clause in the PROC SORT statement to filter out the patients that you do not want to analyze.