BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
92568466
Fluorite | Level 6

I have list of urls of xmls that I need to download. I've the urls in csv (but can covert to any). I'm wondering there's a better way to download all xmls at once from all urls than doing it one by one. I'm currently using the following program to download one by one.

 

filename out "c:\temp\want.xml";
 
proc http
 url='https://s3.amazonaws.com/irs-form-990/201723199349204207_public.xml'
 method="get" out=out;
run;

 

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

You need to also include the FILENAME in the created code, as the OUT= option accepts only file references, not filenames.

filename code temp;
data _null_;
  set LIST ;
  file code;
  put  '
    filename out ' file :$quote. ';'
    / 'proc http method="get"'
     /  ' url='  url :$quote.
     /  ' out=out'
     / ';run;'
  ;
run;

View solution in original post

6 REPLIES 6
Tom
Super User Tom
Super User

Make a SAS dataset that has two character variables. 

URL for the location you want pull from

FILE for the name where you want to save the result.

Then just use a data step to generate a PROC HTTP statement for each observation:

filename code temp;
data _null_;
  set LIST ;
  file code;
  put  'proc http method="get"'
     /  ' url='  url :$quote.
     /  ' out=' file :$quote.
     / ';run;'
  ;
run;

And you can use %INCLUDE to run them.

%include code / source2;
92568466
Fluorite | Level 6

Hi,

I'm not sure what you meant by 'file'. I created a variable named file with the possible names. I tried to run your code, but it didn't work. I got the following error:

"ERROR 22-322: Expecting a name.
ERROR 200-322: The symbol is not recognized and will be ignored."

 

Can you advice on this? I've uploaded data here.

92568466
Fluorite | Level 6

I'm using the following code, as posted by Tom:

 

filename code temp;

data _null_;
set test1;
file code;
put 'proc http method="get"'
/ ' url=' url :$quote.
/ ' out=' file :$quote.
/ ';run;'
;
run;

%include code / source2;

 

Attached are datasets and the log file that shows the error. My objective is to get xmls from the urls (stored in the data set 'test1') and download all to a local folder.

 

Thanks in advance.

Screenshot 2022-03-18 02.59.38.png

Kurt_Bremser
Super User

You need to also include the FILENAME in the created code, as the OUT= option accepts only file references, not filenames.

filename code temp;
data _null_;
  set LIST ;
  file code;
  put  '
    filename out ' file :$quote. ';'
    / 'proc http method="get"'
     /  ' url='  url :$quote.
     /  ' out=out'
     / ';run;'
  ;
run;
92568466
Fluorite | Level 6

Hello @Kurt_Bremser, appreciate your help. The code works great. I'm however running into a related problem that I've posted in as another question. I'm wondering if you can look into that as well.

 

https://communities.sas.com/t5/SAS-Programming/Download-correct-xml/m-p/803612

 

 

Thank you.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 6 replies
  • 713 views
  • 3 likes
  • 3 in conversation