BookmarkSubscribeRSS Feed
cgates
Obsidian | Level 7

I'm using SAS EG, 7.15 HF9 (7.100.5.6226) (64-bit) powered by SAS 9.4. If I paste this link into my browser, a .csv file is automatically downloaded to my PC: https://docs.google.com/spreadsheets/d/1xFgCLi7cr-_Z_hbhksYIv5jABk6EaBcPNWRlVzH5kxY/export?format=cs.... This is a test document but the real data I need to download through SAS has sensitive data so I can't share that here. 

 

The code below works with the test document because there are no restrictions, but when I run the same code with the document that requires me to be signed in, I get HTML output instead of the csv data (copied below).

 

Is there a way I can authenticate my Google credentials through SAS?

filename in url "https://docs.google.com/spreadsheets/d/1xFgCLi7cr-_Z_hbhksYIv5jABk6EaBcPNWRlVzH5kxY/export?format=csv";
filename out "%sysfunc(pathname(work))\data.csv"; 
 
data _null_;                                                                                                                                                      
  infile in;                                                                                                                                                      
  input;                                                                                                                                                          
  if _n_> 1;                                                                                                                                                     
  file out;                                                                                                                                                       
  put _infile_;                                                                                                                                                   
run;                                                                                                                                                              
                                                                                                                                                                  
PROC IMPORT OUT= WORK.data                                                                                                                                        
     DATAFILE= "%sysfunc(pathname(work))\data.csv"                                                                                                 
     DBMS=CSV REPLACE;                                                                                                                                            
RUN;

.csv snippet from SAS in HTML

<!DOCTYPE html>
<html lang="en">
  <head>
  <meta charset="utf-8">
  <meta content="width=300
  <meta name="description" content="Create a new spreadsheet and edit with others at the same time -- from your computer
  <meta name="google-site-verification" content="LrdTUW9psUAMbh4Ia074-BPEVmcpBxF6Gwf0MSgQXZs">
  <title>Google Sheets - create and edit spreadsheets online
  <style>
  @font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 300;
  src: url(//fonts.gstatic.com/s/opensans/v15/mem5YaGs126MiZpBA-UN_r8OUuhs.ttf) format('truetype');
}

 

4 REPLIES 4
japelin
Rhodochrosite | Level 12

I don't think this is a SAS problem.

To test, try accessing the spreadsheet link in another browser without cache or in private mode.
If it doesn't download as a CSV, you will first need to change the sharing range to "Everyone who knows the link" in Google Spreadsheets.
Then you should be able to download it as a csv.

cgates
Obsidian | Level 7

You're right. The link I provided was just an example but it does work if I remove restrictions. The issue is the production link I need this for does need to be protected. Do you know of a way I can authenticate my Google credentials through SAS? I thought it would work because I was running the SAS program while logged into my Gmail but that doesn't seem to work. 

japelin
Rhodochrosite | Level 12

I thought I could access it with proc http and basic authentication if I had the app password, but it seems that OAuth is required to access it.

 

The following links may be helpful.

https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2019/3232-2019.pdf

https://support.sas.com/resources/papers/proceedings17/SAS0224-2017.pdf

 

PhilC
Rhodochrosite | Level 12

The content sharing access permissions for Google Docs can be set to not require authentication.  My memory, you can set (paraphrasing) "Share to whom ever has the link".  I don't use it often, and I have to stumble through their security access menus re-re-learning it every time.  Something to consider, HTH.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

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
  • 4 replies
  • 782 views
  • 0 likes
  • 3 in conversation