Hi,
I have below data, how can I count number of missing dates within a group? Here I have provided only one id and one visit. I have large data.
here number of missing dates by id and visit are 5 (20JUL2018, 21JUL2018, 22JUL2018, 24JUL2018, 25JUL2018).
data have;
input date $1-10 id $12-15 visit $17-25;
datalines;
19JUL2018 001 Baseline
23JUL2018 001 Baseline
26JUL2018 001 Baseline
27JUL2018 001 Baseline
28JUL2018 001 Baseline
;
run;Thanks,
Chinna
data have;
input date :date9. id $ visit $;
format date date9.;
datalines;
19JUL2018 001 Baseline
23JUL2018 001 Baseline
26JUL2018 001 Baseline
27JUL2018 001 Baseline
28JUL2018 001 Baseline
;
run;
proc sql;
create table want as
select id,visit,range(date)+1-count(distinct date) as n_miss_date
from have
group by id,visit;
quit;
data have;
input date :date9. id $ visit $;
format date date9.;
datalines;
19JUL2018 001 Baseline
23JUL2018 001 Baseline
26JUL2018 001 Baseline
27JUL2018 001 Baseline
28JUL2018 001 Baseline
;
run;
proc sql;
create table want as
select id,visit,range(date)+1-count(distinct date) as n_miss_date
from have
group by id,visit;
quit;
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 save with the early bird rate—just $795!
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.