BookmarkSubscribeRSS Feed
LOLO12
Obsidian | Level 7

I'm trying to import data from this site 

https://polygon.io/docs/stocks/getting-started

 

by SAS viya or SAS Window. 

I have tried few codes and was not successful. 

5 REPLIES 5
Reeza
Super User
Please include any code you've tried.

Assuming you're doing something like this: https://blogs.sas.com/content/sasdummy/2018/01/16/hide-rest-api-tokens/

ChrisHemedinger
Community Manager

I signed up for an API key (free) so I could try this. In SAS it's straightforward. Here's my code using their sample call:

 

 

filename resp temp;

proc http
 url="https://api.polygon.io/v2/aggs/ticker/AAPL/range/1/day/2021-07-22/2021-07-22?adjusted=true&sort=asc&limit=120"
 out=resp
 oauth_bearer="your-api-key";
run;

libname data json fileref=resp;
proc print data=data.results;
run;
 

 

Output:

ChrisHemedinger_0-1645971976092.png

Instead of the OAUTH_BEARER option (shorthand for the OAuth pattern), you can also use the HEADERS statement:

 

proc http
 url="api-call"
 out=resp;
 headers 
  "Authorization" = "Bearer your-auth-key";
run;

 

 

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
LOLO12
Obsidian | Level 7

I tried this code and still not working 

 

proc http
url="https://api.polygon.io/v2/aggs/ticker/AAPL/range/1/day/2021-07-22/2021-07-22?adjusted=true&sort=asc&..."
out=resp;
headers
"Authorization" = "Bearer <token>";
run;

 

 

mona12_0-1646245176168.png

 

Reeza
Super User

Delete your token from the message.

ChrisHemedinger
Community Manager

Can you make any PROC HTTP calls to the internet in SAS? Try the steps in this blog post. You might need to specify a proxy host.

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1069 views
  • 2 likes
  • 3 in conversation