Hello all.
I would like to complete the table on the left side with a variable time span based on the years.
I hope that you can help me.
Hi @cnn96
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;
Thank you very much. This way it worked the way i wanted it to.😊
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.