I am very new to SAS and I am trying to iterate over a set of SAS files in a library. They all have names like filename_2022xxxx where 'xxxx' is the day and month the file was created. For each file I will create the same tables which will be appended to a main CSV export file. The following pseudo code is representative of what I would like to do. For file in lib with name like filename_* Let expstamp = * /*the specific date stamp (expstamp) of the file is needed for reference in the creation of a subsequent table */ Create Table A /*Create table with Proc SQL, subsequent tables will reference this table A rather than the original dataset */ Create Table B Create Table C /* this table needs a column with exp_stamp variable */ If export file does not exist: Create export csv file Else concatenate output to existing output csv End. I am having no trouble with the creation of my tables beyond the fact that I have to hardcode file names into my script, which is what I am looking to avoid since there are numerous files. I am not able to attach the data but would like an idea of how to approach this. I have successfully added a column with the date stamp from the original data set by the following method with aforementioned hardcoding: data lib.temp;
set lib.filename_20220722
indsname = name;
EXP_STAMP = scan(scan(name, 2),3,'_');
run;
I am unsure if there is an optimal method that does not require nesting scan functions.
... View more