BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
A_SAS_Man
Pyrite | Level 9

I am wondering how to convert a table on a website into a SAS data set. I'm trying to do this on a somewhat regular basis, so I'm trying to find a good way to automate it. The website I'm trying to access is: https://covidtracking.com/data/state/california#historical

 

The table I'm trying to access is the "History" table.

 

I realize some parsing is needed, but I seem to be unable to even locate the data in my sas session. When I run the following code I don't get any errors, but I am unable to access the data "src" anywhere as far as I can tell.

 

filename src temp;
proc http
method="GET"
url="https://covidtracking.com/data/state/california#historical"
out=src;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
AhmedAl_Attar
Rhodochrosite | Level 12

I think you would be better served by using the json data from the same web site https://covidtracking.com/api.

Based on their api documentation on the same web site, here is how you can California Historical data into a SAS data set

filename resp temp;
 
/* Neat service from Open Notify project */
proc http 
 url="https://covidtracking.com/api/v1/states/CA/daily.json"
 method= "GET"
 out=resp;
run;
 
/* Assign a JSON library to the HTTP response */
libname covid JSON fileref=resp;
 
proc print data=covid.root (drop=ordinal:);
run;

Hope this helps,

Ahmed

View solution in original post

2 REPLIES 2
Reeza
Super User

https://data.chhs.ca.gov/dataset/california-covid-19-hospital-data-and-case-statistics/resource/6cd8...

 

What about this source instead? From the open data portal and the API guide is there.

 

 

AhmedAl_Attar
Rhodochrosite | Level 12

I think you would be better served by using the json data from the same web site https://covidtracking.com/api.

Based on their api documentation on the same web site, here is how you can California Historical data into a SAS data set

filename resp temp;
 
/* Neat service from Open Notify project */
proc http 
 url="https://covidtracking.com/api/v1/states/CA/daily.json"
 method= "GET"
 out=resp;
run;
 
/* Assign a JSON library to the HTTP response */
libname covid JSON fileref=resp;
 
proc print data=covid.root (drop=ordinal:);
run;

Hope this helps,

Ahmed

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

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
  • 2 replies
  • 846 views
  • 2 likes
  • 3 in conversation