Professional Documents
Culture Documents
Coders'
Paper 73-28
®
The URL-y Show: Using SAS LE and the URL Access Method to Retrieve Stock Quotes
Ted Conway, Ted Conway Consulting, Inc., Chicago, IL
A brief SAS program and short macro are presented that Two programs are provided in the following sections together with
illustrate ways that the SAS URL access method can be used to sample output to illustrate how the URL access method can be
retrieve stock quotes from the Web. This technique, which can be used to retrieve stock quotes from the web:
used to retrieve all kinds of data from Intranet and Internet sites,
may be of interest to anyone who uses SAS LE or Base SAS on Ticker.sas is a simple program that retrieves and prints quotes
the PC platform. for the specified symbols.
proxy='http://proxy.….com:port' YHOO 17.50 12/16/2002 11:20am 0.10 17.38 17.59 17.27 3155820
user='…' pass='…'; IBM 79.74 12/16/2002 11:16am -0.26 79.60 80.00 79.05 2674300
HPQ 18.87 12/16/2002 11:16am 0.37 18.91 19.00 18.65 2956700
On most web pages, the data returned will include HTML
formatting, so be aware that you’ll probably have to do some
character string manipulation to get the desired data.
1
SUGI 28 Coder's Corner
Coders'
data;
%if &i<=&max %then CONCLUSION
x=sleep(&sleep);;
run; With the addition of the URL access method, SAS has really
made reading web pages a breeze - see what you can come up
%end; with!