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;
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
What about this source instead? From the open data portal and the API guide is there.
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.