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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 1186 views
  • 3 likes
  • 3 in conversation