Not sure if this is what you are looking for. The code below goes out and grabs all the files in a directory and creates variable from the file names. I included a link to the External File Functions.
/*
External File Functions
https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=allprodsle&docsetTarget=syntaxByCategory-function.htm&locale=en#n1xjxmfjlyclzjn1hyatp8m76hr7
*/
filename myDir "\Some\folder\some\where" ;
data want ;
/* get a directory handle for the directory */
dirRC=dopen("myDir") ;
put dirRC= ;
/* get the number of files in the directory */
dNum=dnum(dirRC) ;
put dNum= ;
/* loop through the files */
do i=1 to dnum ;
/* get the filename */
filename=dread(dirRC,i) ;
put filename= ;
/* now do whatever you want with the filename */
var1=substr(filename,1,4) ;
output ;
end ;
run ;
... View more