Dear All, I need to call multiple datasets from the same library in SAS and change the format of one variable called DATE1 in both datasets. All the datasets have the same column variables because I have one dataset per year. I have managed to do it by using the following code (case 2 datasets): data dataset1 dataset2; set exp.dataset1 exp.dataset2 ; date1_mod = INPUT(PUT(date1,8.),YYMMDD8.); format date1_mod YYMMDD8. run; This code works, but I would like to ask you whether there is a more efficient way to do it (I may need to call 15-20 datasets). Once I import the datasets, I need to use PROC SQL and CREATE TABLE in order to perform another operation on both datasets. The code below works in the case of a single dataset, but it fails with multiple datasets. My first attempt tries to extend the case with 1 dataset in the following way: proc sql; create table mod_dataset1 mod_dataset2 as select V1, V2, V3, V4, V5, V6, month(date1_mod) as month from dataset1 dataset2 group by V1, calculated month having date1_mod=max(date1_mod); quit; My second attempt involves the creation of a function MYFUN. This doesn't work either. * creating function myfun; function myfun(dataset); proc sql; create table newdataset as select V1, V2, V3, V4, V5, V6, month(date1_mod) as month from dataset group by V1, calculated month having date1_mod=max(date1_mod); quit; endsub; run; * calling function myfun; newdataset = myfun(dataset); Any help would be highly appreciated.
... View more