I think this will do it.
First use a select to calculate the time_span for each PatientID then add the calculated value with a join.
Note: Untested, because you didn't provide a data step to generate test data.
proc sql; create table b as select distinct PatientID, count(*) as time_span from mylib.mytable group by PatientID; quit; proc sql; create table table_timespan as select a.*, b.time_span from mylib.mytable as a, b on a.PatientID = b.PatientID; quit;
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.