BookmarkSubscribeRSS Feed
stf5018
SAS Employee

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

7f218312-a3d2-4034-abde-574087c85fc2.png

b065b66e-996a-440b-8aef-5d0c34abd228.png

 

 

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;

 

2 REPLIES 2

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 288 views
  • 0 likes
  • 2 in conversation