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
Amethyst | Level 16

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



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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 1248 views
  • 2 likes
  • 2 in conversation