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
😞
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.