BookmarkSubscribeRSS Feed
avinashginjupal
Obsidian | Level 7

Many of our users are doing a lot of weekly and daily updates on some publicly available contents, a good example here would be the 7 days COVID cases that is retrievable here at: https://covid.cdc.gov/covid-data-tracker/#cases_casesper100klast7days. 

 

My question is really an intuitive one: instead of having human interference and manually clicking that 'download' button each time to get the latest case numbers as a .csv file, is there a way to download the file using some kind of SAS procedure?

 

While my SAS and HTML knowledge is limited, I have tried a few things such as PROC HTTP, but the webpage seems to be using some level of javascript and therefore the static methods which I researched turned out to be not as useful as they should be otherwise.

 

From my own experience I've utilized web scrapping tools available with python or r to handle an interactive webpage like this, but now SAS is the only tool I am having access to, which ultimately brought me to here to seek some advices on this technical miscellany. Many thanks to anyone who could leave their thoughts!

1 REPLY 1
yabwon
Onyx | Level 15

If you know exact URL for the file you can do it like this:

filename in  URL 'https://covid.cdc.gov/XXXXXXXXX/united_states_covid19_cases_and_deaths_by_state.csv' lrecl=1 recfm=n;
filename out     "%sysfunc(pathname(work))/united_states_covid19_cases_and_deaths_by_state.csv" lrecl=1 recfm=n;

data _null_;
  rc = fcopy('in', 'out');
  if rc then put "Error: " rc=;
run;

filename in  clear;
filename out clear;

B

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



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
  • 1 reply
  • 634 views
  • 2 likes
  • 2 in conversation