Suppose I download a webpage via PROC HTTP.
filename myfile 'myfile.htm'; proc http url='https://www.macrotrends.net/stocks/charts/KO/cocacola/balance-sheet' out=myfile; run;
Successful downloading returns NOTE: 200 OK as follows:
1 filename myfile 'myfile.htm';
2
3 proc http url='https://www.macrotrends.net/stocks/charts/KO/cocacola/balance-sheet' out=myfile; 4 run; NOTE: 200 OK NOTE: PROCEDURE HTTP used (Total process time): real time 0.05 seconds cpu time 0.00 seconds
Instead, unsuccessful downloading returns NOTE: 429 O as follows:
1 filename myfile 'myfile.htm';
2
3 proc http url='https://www.macrotrends.net/stocks/charts/KO/cocacola/balance-sheet' out=myfile;
4 run;
NOTE: 429 O
NOTE: PROCEDURE HTTP used (Total process time):
real time 0.05 seconds
cpu time 0.00 secondsIs there any easy way to extract the "200" or "429" as a macro variable? Though I can output the log and infile it with symputx as follows, I wonder if there are easier ways than this.
filename myfile 'myfile.htm';
proc printto log='mylog.log';
run;
proc http url='https://www.macrotrends.net/stocks/charts/KO/cocacola/balance-sheet' out=myfile;
run;
proc printto;
run;
data _null_;
infile 'mylog.log' truncover;
input;
if scan(lag3(_infile_),3)='http' then call symputx('note',scan(_infile_,2));
run;
%put ¬e;
data _null_;
infile 'del mylog.log' pipe;
run;Thanks for any helpful suggestions.
SAS will create and populate two automatic macro variables.
SAS will create and populate two automatic macro variables.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.