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
Meteorite | Level 14

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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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