I have many different datasets within a particularly library, and I'm wondering whether there is a way to find a minimum and maximum date associated with a particular unique ID across ALL datasets in a library?
Currently, I can find a local minimum and local maximum date associated with a particular ID within a particular dataset, but this ID will show up again throughout different datasets and have it's own minimum/max date associated with that dataset. But I want to compare the dates on this particular unique ID throughout the entire library, so I can find the global minimum and global maximum date but I do not know how to do this search throughout the entire library.
Currently my code looks like the following
DATA SUBSET_MIN_MAX (keep= MIN_DATE MAX_DATE UNIQUEID);
DO UNTIL (LAST.UNIQUEID);
set LIBRARY.&SAS_FILE_N;
BY UNIQUEID;
MIN_DATE = MIN(MIN_DATE,DATE);
MAX_DATE = MAX(MAX_DATE,DATE);
if last.UNIQUEID then output;
END;
format MIN_DATE MAX_DATE date9.;
RUN;
Thanks so much for any assistance.
Consider this using a view and PROC SUMMARY.
data d1; set sashelp.class; date=height+ranuni(4); run;
data d2; set sashelp.class; date=height-rannor(5); run;
data d3; set sashelp.class; date=height-ranuni(3); run;
data alld/view=alld;
length indsname $64;
set work.d:(keep=name date) indsname=indsname;
source=indsname;
run;
proc summary data=alld nway missing;
class name;
var date;
output out=want(drop=_type_)
idgroup(max(date) out(source date)=source1 globalmax)
idgroup(min(date) out(source date)=source2 globalmin)
;
run;
proc print;
run;