I usually mess with this Tidy Tuesday data in R, but I want to try it in SAS this week as practice. I am having some trouble importing it into SAS Studio.
Data page - https://github.com/rfordatascience/tidytuesday/blob/master/data/2021/2021-08-31/readme.md
Direct link to csv - https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-08-31/bird_baths...
I have a few questions. Below is my code.
1 - Why am I getting an error trying to import the data directly from my PC after downloading the file?
2 - I uploaded the file directly to SAS Studio and was able to interact with it.
3 - I tried to import the data directly from the web CSV and I do not get an error, but when I try to print it to see if it exists I do get an error. How do I know if it correctly downloaded and what do I need to change in the code to be able to print the data?
* 1
ERROR: Physical file does not exist, /pbr/biconfig/940/Lev1/SASApp/C:/Users/Jason/Documents/R/Tidy Tuesday/BirdBaths/birdbaths.csv. ERROR: Import unsuccessful. See SAS Log for details.; proc import file="C:/Users/Jason/Documents/R/Tidy Tuesday/BirdBaths/birdbaths.csv" out=birdbathsPC dbms=csv; run;
* 2 * THIS WORKS * Need to figure out how to do it without uploading to SAS; proc import file="/home/u59127222/SP4R/birdbaths.csv" out=birdbaths dbms=csv; run; proc print data=birdbaths (obs=6); run; * 3 * Testing downloading directly from the web * https://github.com/rfordatascience/tidytuesday/blob/master/data/2021/2021-08-31/readme.md * https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-08-31/bird_baths.csv; * https://blogs.sas.com/content/sasdummy/2017/05/07/download-convert-csv-files/; filename probly temp; proc http url="https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-08-31/bird_baths.csv" method="GET" out=probly; run; * ERROR: File WORK.PROBLY.DATA does not exist; proc print data=WORK.probly (obs=6); run;
* ERROR: File WORK.PROBLY.DATA does not exist;
proc print data=probly (obs=6);
run;
URL method is pretty close, you need to import it as well as download it though. PROC HTTP downloads the file, PROC IMPORT will then read the file.
https://blogs.sas.com/content/sasdummy/2017/05/07/download-convert-csv-files/
filename probly temp;
proc http url="https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-08-31/bird_baths.csv"
method="GET"
out=probly;
run;
proc import out=bird_baths datafile=probly dbms=csv replace; guessingrows = max; run;
proc print data=bird_baths (obs=10);
run;
@Indescribled wrote:
I usually mess with this Tidy Tuesday data in R, but I want to try it in SAS this week as practice. I am having some trouble importing it into SAS Studio.
Data page - https://github.com/rfordatascience/tidytuesday/blob/master/data/2021/2021-08-31/readme.md
Direct link to csv - https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-08-31/bird_baths...
I have a few questions. Below is my code.
1 - Why am I getting an error trying to import the data directly from my PC after downloading the file?
2 - I uploaded the file directly to SAS Studio and was able to interact with it.
3 - I tried to import the data directly from the web CSV and I do not get an error, but when I try to print it to see if it exists I do get an error. How do I know if it correctly downloaded and what do I need to change in the code to be able to print the data?
* 1
ERROR: Physical file does not exist, /pbr/biconfig/940/Lev1/SASApp/C:/Users/Jason/Documents/R/Tidy Tuesday/BirdBaths/birdbaths.csv. ERROR: Import unsuccessful. See SAS Log for details.; proc import file="C:/Users/Jason/Documents/R/Tidy Tuesday/BirdBaths/birdbaths.csv" out=birdbathsPC dbms=csv; run;
* 2 * THIS WORKS * Need to figure out how to do it without uploading to SAS; proc import file="/home/u59127222/SP4R/birdbaths.csv" out=birdbaths dbms=csv; run; proc print data=birdbaths (obs=6); run; * 3 * Testing downloading directly from the web * https://github.com/rfordatascience/tidytuesday/blob/master/data/2021/2021-08-31/readme.md * https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-08-31/bird_baths.csv; * https://blogs.sas.com/content/sasdummy/2017/05/07/download-convert-csv-files/; filename probly temp; proc http url="https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-08-31/bird_baths.csv" method="GET" out=probly; run; * ERROR: File WORK.PROBLY.DATA does not exist; proc print data=WORK.probly (obs=6); run;
* ERROR: File WORK.PROBLY.DATA does not exist;
proc print data=probly (obs=6);
run;
URL method is pretty close, you need to import it as well as download it though. PROC HTTP downloads the file, PROC IMPORT will then read the file.
https://blogs.sas.com/content/sasdummy/2017/05/07/download-convert-csv-files/
filename probly temp;
proc http url="https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-08-31/bird_baths.csv"
method="GET"
out=probly;
run;
proc import out=bird_baths datafile=probly dbms=csv replace; guessingrows = max; run;
proc print data=bird_baths (obs=10);
run;
@Indescribled wrote:
I usually mess with this Tidy Tuesday data in R, but I want to try it in SAS this week as practice. I am having some trouble importing it into SAS Studio.
Data page - https://github.com/rfordatascience/tidytuesday/blob/master/data/2021/2021-08-31/readme.md
Direct link to csv - https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-08-31/bird_baths...
I have a few questions. Below is my code.
1 - Why am I getting an error trying to import the data directly from my PC after downloading the file?
2 - I uploaded the file directly to SAS Studio and was able to interact with it.
3 - I tried to import the data directly from the web CSV and I do not get an error, but when I try to print it to see if it exists I do get an error. How do I know if it correctly downloaded and what do I need to change in the code to be able to print the data?
* 1
ERROR: Physical file does not exist, /pbr/biconfig/940/Lev1/SASApp/C:/Users/Jason/Documents/R/Tidy Tuesday/BirdBaths/birdbaths.csv. ERROR: Import unsuccessful. See SAS Log for details.; proc import file="C:/Users/Jason/Documents/R/Tidy Tuesday/BirdBaths/birdbaths.csv" out=birdbathsPC dbms=csv; run;
* 2 * THIS WORKS * Need to figure out how to do it without uploading to SAS; proc import file="/home/u59127222/SP4R/birdbaths.csv" out=birdbaths dbms=csv; run; proc print data=birdbaths (obs=6); run; * 3 * Testing downloading directly from the web * https://github.com/rfordatascience/tidytuesday/blob/master/data/2021/2021-08-31/readme.md * https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-08-31/bird_baths.csv; * https://blogs.sas.com/content/sasdummy/2017/05/07/download-convert-csv-files/; filename probly temp; proc http url="https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-08-31/bird_baths.csv" method="GET" out=probly; run; * ERROR: File WORK.PROBLY.DATA does not exist; proc print data=WORK.probly (obs=6); run;
* ERROR: File WORK.PROBLY.DATA does not exist;
proc print data=probly (obs=6);
run;
Large economy sized hint: Do not place punctuation immediately after a URL in message window as link. The semicolon you added at the end of the URL becomes part of it and the link shows a 404 File not found error because of it. (Not the code, the "direct link" in the thread text)
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.