I am building a dataset from several large date dependent datasets created by another user. The dataset name has the date value in it. I want to capture the datevalue from the users dataset name and add it to a new variable on my datset.
For example if dataset a contained the name testresults01/01/2009, I will take all the data elements from testresults01/01/2009 and add a variable which contains the value 01/01/2009.
Explore using the "pathname" function and consider that some characters are not acceptable in a SAS variable name. So, you will likely already have a "libref" setup before your DATA step, so you will need to consider how to pre-process the info returned from the pathname function, either in a different DATA step or by using MACRO language and %SYSFUNC(pathname()) to assign a macro variable. Then this macro variable would be used later in your input processing DATA step to read the actual file and populate your variables.
Let's simulate some data to illustrate the program:
do i=1 to 10000;
when(mod(i,3)=0) output T01_20091001;
when(mod(i,3)=1) output T01_20091002;
when(mod(i,3)=2) output T01_20091003;
otherwise put "Never seen !";
This macro will append the content of the file T01_date to T04_union. The date is added to the input file before the append takes place. This is done with a "view" (this doesn't require disk space)
create view T03_temp as
select input("&date",yymmdd8.) format=date9. as date, *
proc append data=T03_temp out=T04_union;
drop view T03_temp;
Let us invoke the macro "manually"
* import 1 file manually;
You can generate macro calls using a data step
* import multiple files from list in T02_metadata;
You could add some code in the macro to handle re-loads.