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
Ammonite | Level 13

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
Ammonite | Level 13

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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1124 views
  • 2 likes
  • 3 in conversation