I am trying to get the names of all files (including file extension) that are contained in an Azure Data Lake and put them in a table using a loop that goes through the directory. My code can successfully get all the files, starting at a user-supplied base directory, and store their names using the "dread" but it cuts off the last character. How do I get the full name (including extension) without the last character missing? I don't understand why the last character is cut off. I have tried different files, file types, folders, and all combinations thereof.
Code is below along with screenshots of what's contained in ADLS and the "files" table I am storing the output of the code in. Notice that the table has "ds_0" instead of "ds_01" and "process.cs" instead of "process.csv".
Images: (Left) Azure Data Lake Container, (Right) SAS table with filenames
options azuretenantid = "###-###-###-";
%let appId="###-###-###-";
%let acctName="###";
%let filesys="###";
filename d adls "/"
applicationId=&appId
accountname=&acctName
filesystem=&filesys;
data files;
folder_id = dopen("d");
put folder_id=;
num_files = dnum(folder_id);
put num_files=;
do i = 1 to num_files;
length name $256 ;
name=dread(folder_id,i);
output;
end;
closerc = dclose(folder_id);
put closerc=;
run;
I would open a ticket with SAS support. https://support.sas.com/en/technical-support/submit-a-support-request.html
😞
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.