Hi guys,
suppose to have a number of folders:
Folder Tokyo: "C:\Users\....\Tokyo"
Folder NYC: "C:\Users\....\NYC"
Folder Singapore: "C:\Users\....\Singapore"
Each folder contains different files named identical across the folders: Hospitalization_flu, Hospitalization_Covid, ....
The files appear like this:
data Hospitalization_flu ;
input ID:$20. Admission :date09. Discharge :date09. Sex Morbidity;
format Admission date9. Discharge date9.;
cards;
0001 13JAN2017 25JAN2017 M Yes
0001 22FEB2018 03MAR2018 M No
0001 22FEB2018 03MAR2018 M Yes
0002 01DEC2016 14DEC2016 F No
0002 01DEC2016 14DEC2016 F No
0002 25DEC2017 02JAN2018 F No
0002 06JAN2018 09JAN2018 F Yes
;run;
I would like to append (vertically with set) all files with the same name from different folders, for example all "Hospitalization_flu" files to generate a unique Hospitalization_flu file but:
the files, for example Hospitalization_flu files have a variable number of columns but a set of common columns like ID, Admission, Discharge, .... I'm not interested in extra columns but I would like to take only the common variables.
the order of variables is not the same so the files should be sorted to have the same order
I would like to add an extra variable that takes the name of the folder of origin in order to track the source folder
The folders are around 20 and so totally I have 20 files named for example "Hospitalization_flu", 20 named "Hospitalization_Covid" and so on. Moreover the files contain around 70 variables and to sort them manually is not feasible.
Note that IDs present in different files/folders are unique since from an anonymization process and files are SAS datasets.
Can anyone help me please to automate the process?
Thank you in advance
... View more