Help using Base SAS procedures

List all files in URL

Reply
Regular Contributor
Regular Contributor
Posts: 166

List all files in URL

Hi All,

I have a url for example

http://myserver:81/path/

When i open this path on an internet explorer i can see all the .txt files available in this directory. It appears as a complete list with file name,  created date etc:

I wish to know using sas can we list out all the files present in this path.

Kindly guide or any references will also help.

Thanks..

Super User
Posts: 9,687

Re: List all files in URL

There is an example in Arthur.T 's paper at SGF2012 (Sometimes One Needs an Option with Unusual Dates) .

The following is a code fragment from his Paper .

This remind me that I haven't see him for a long time at this forum .

%macro getcdates;

  %do i=1901 %to 2100;

    filename lunar http

"http://www.hko.gov.hk/gts/time/calendar/text/T&i.e.txt";

    data temp;

      format Gregorian_date yymmdd10.;

      infile lunar dlm=' ' firstobs=3 truncover expandtabs ;

      input Gregorian_date : ?? yymmdd12. lunar_date & $40.

            day_of_week : $20.            solar_term &  $40.;

      if not missing(Gregorian_date) then output;

    run;

    proc append base=dates data=temp; run;

  %end;

Ksharp

Regular Contributor
Regular Contributor
Posts: 166

Re: List all files in URL

Thanks Ksharp..

I already had a program like above in place ....

But the restriction of this is that we are assuming the Files name to be in a specified format.

My concern was that if the files had random names would i be able to list all these files...

Super User
Posts: 9,687

Re: List all files in URL

Yes. You can extract these file name from you URL firstly, then feed them to a seriers of macro variables and you can input them. Like something:

filename x url 'http://www.hko.gov.hk/gts/time/calendar/text/';
data _null_;
 infile x length=len;
 input x $varying200. len;
 /*Code here to extract the file name you need */
run;

Ksharp

Ask a Question
Discussion stats
  • 3 replies
  • 233 views
  • 3 likes
  • 2 in conversation