02-03-2015 11:53 AM
I have a library "have" which contains dataset of each day. e.g data20150101,data20150102,data20150105...
and some irrelevant dataset e.g irrelevant1, irrelevant2, irrelevant3..
Sat and Sun dataset are not available. i.e no data20150103, data20150104
I want to create a new dataset "want" combining all the daily files for a month but not those irrelevant dataset,
any possible way to do it automatically? I am now doing it manually with set statement..
Thanks so much for the help!
02-03-2015 12:21 PM
If the irrelevant data sets do not begin with DATA201501 then:
set data201501: ;
would work to combine all of the, I assume January data sets.
If you are placing the resulting data set in the same library then you may not want to name it data201501<anything> as this code will then append this dataset as well.
02-03-2015 09:17 PM
02-03-2015 08:41 PM
I'd go with a macro-based solution that contains a loop with a supplied starting date and end date. I would also use the EXIST function to be able to report on any days where there is no dataset and to add to the SET statement only datasets that exist.
02-04-2015 02:05 AM
Use dictionary table to pick up these wanted tables.
data data20150101 data20150102 data20150103 data20150104 data20150105 irrelevant1 irrelevant2 irrelevant3; infile cards dsd truncover; input id : $20. i : $20. @; id=compress(id,,'kd'); retain v 1; do until(missing(i)); output; input i : $20. @; end; cards; ID1, ID2,Trait1,Trait2,Trait3 ID3,Trait2,Trait3,Trait5 ID4,Trait5 ID5,Trait1 ;;;; run; proc sql; select memname into : list separated by ' ' from dictionary.members where libname='WORK' and memtype='DATA' and weekday(input(compress(memname,,'kd'), anydtdte.)) in (2:6); quit; data want; length tname $ 40; set &list indsname=indsname; tname=indsname; run;