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.
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;
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;
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.
Please post the complete (code and messages) log of the failing step into a window opened with this button:
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.
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;
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.
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!
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.