DATA Step, Macro, Functions and more

Read Data from URL in SAS

Reply
Regular Contributor
Posts: 195

Read Data from URL in SAS

Hi All,

I am trying to read data from one of the following link

https://in.finance.yahoo.com/q?s=%5EHSI&ql=1


I can create HTML page by using proc http...


But can anyone suggest how to read the data directly from the above link...Please note that data is not saved in file format...It is just displayed in link and i want to read from that...


Thanks in advance...


-Urvish

Super User
Posts: 7,832

Re: Read Data from URL in SAS

Posted in reply to UrvishShah

"Internal Server Error" when trying your URL.

Update: replace the ^ with %

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Super User
Posts: 7,977

Re: Read Data from URL in SAS

Posted in reply to UrvishShah

Hi,

What exactly are you trying to read from that page.  It looks like a straight forward HTML document (right click and view source).  If its something specific then you need to read it in as text and identify the elements you want to pull out, i.e. look for

"HANG SENG INDEX (^HSI)"

In the read in text, and then read and parse from there.

Regular Contributor
Posts: 168

Re: Read Data from URL in SAS

In the interst of time, may I ask how to read and parse "HANG SENG INDEX (^HSI)" from the given URL?

Super User
Super User
Posts: 7,977

Re: Read Data from URL in SAS

Well, you mention that you have: "I can create HTML page by using proc http..."

So you then just need to do a datastep with an infile.  Read the whole text file in and using findc() or index() search for the data you are after.  Once you know where it is then you parse the HTML tags to get the actual data.

Super User
Posts: 10,041

Re: Read Data from URL in SAS

Posted in reply to UrvishShah

You are connecting a encrypt URL . Check proc http documentation

Making PROC HTTP Calls by Using the HTTPS Protocol
In order to make PROC HTTP calls by using the HTTPS protocol, you must configure
a trust source that contains the certificate of the service to be trusted. This trust source
and its password must be provided for the SAS session by setting Java system options
using jreoptions. You can provide this information on the SAS command line or in a
SAS configuration file. Use the following syntax. Be sure to enter the following entry on
one line:
-jreoptions (-Djavax.net.ssl.trustStore=full-path-to-the-trust-store -
Djavax.net.ssl.trustStorePassword=trustStorePassword)
The following example shows how to use the entry on the SAS command line. This
example uses the Windows operating environment. Be sure to enter the following entry
on one line:
"C:\Program Files\SAS\SASFoundation\9.2\sas.exe" -CONFIG
"C:\Program Files\SAS\SASFoundation\9.2\nls\en\SASV9.CFG"
-jreoptions (- Djavax.net.ssl.trustStore=C:\Documents and Settings\mydir\.keystore
-Djavax.net.ssl.trustStorePassword=trustpassword)


Xia Keshan

Ask a Question
Discussion stats
  • 5 replies
  • 401 views
  • 0 likes
  • 5 in conversation