Desktop productivity for business analysts and programmers

Read Excel file from metadata

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 10
Accepted Solution

Read Excel file from metadata

Hello all,

 

I use an Excel file as a source for an ETL Process. The file will be edit by users in Excel and opened / saved with the SAS Excel Addin (function Extras -> save in sas folder). Also the file is stored in metadata.

 

My problem is: how  can I access the content of the file in EG or as user written code in DI-Studio?

 

Any ideas?


Accepted Solutions
Solution
‎07-26-2016 03:57 AM
Community Manager
Posts: 2,697

Re: Read Excel file from metadata

[ Edited ]

When a file is "saved in metadata", usually that means in a SAS metadata folder.  The information is registered in metadata, while the physical file is stored in the SAS Content Server.  The SAS Content Server is a WebDAV-compliant HTTP server.

 

PROC HTTP can be used to access, if you know the URL/port and the metadata path and have the proper credentials.  Here's an example:

 

filename xlsout "%sysfunc(getoption(WORK))/file.xlsx";

%let server=http://yourserver.company.com:7980/SASContentServer;

proc http  
url="&server./repository/default/sasfolders/Shared%20Data/stp_samples/file.xlsx"
  WEBUSERNAME="xxxxx"
  webpassword="xxxxx"
  method="GET"
  OUT=xlsout
;
run;

proc import datafile=xlsout
 out=result
 replace
 dbms=xlsx;
run;

View solution in original post


All Replies
Esteemed Advisor
Posts: 6,684

Re: Read Excel file from metadata

If you need a way for users to input data, wouldn't it be easier to write a stored process that stores directly to a SAS dataset?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 10

Re: Read Excel file from metadata

It would be a big overhead for our problem :-(
Esteemed Advisor
Posts: 6,684

Re: Read Excel file from metadata


arial34 wrote:
It would be a big overhead for our problem :-(

Absolutely not. It would take the execrable Excel out of the process, only need a web browser for users, and you could even code sanity checks into the STP (or the web form, using javascript).

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Trusted Advisor
Posts: 1,059

Re: Read Excel file from metadata

Can you elaborate a little on "also the file is stored in metadata". In what form? How do you get it into the metadata server?

 

Tom

Occasional Contributor
Posts: 10

Re: Read Excel file from metadata

User opens an excel sheet using the SAS excel addin. Then after edit user saves file with the same addin in a defined folder. So the file content is stored not in the file system.

Esteemed Advisor
Posts: 6,684

Re: Read Excel file from metadata

@TomKari, I just tried that for the first time. The MS Office Add-In allows storing of Office documents into the metadata folders. Some checks did not yet reveal if the documents are put into the metadata repository itself or stored via webdav into the SAS Content Server (with a link in the metadata).

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Solution
‎07-26-2016 03:57 AM
Community Manager
Posts: 2,697

Re: Read Excel file from metadata

[ Edited ]

When a file is "saved in metadata", usually that means in a SAS metadata folder.  The information is registered in metadata, while the physical file is stored in the SAS Content Server.  The SAS Content Server is a WebDAV-compliant HTTP server.

 

PROC HTTP can be used to access, if you know the URL/port and the metadata path and have the proper credentials.  Here's an example:

 

filename xlsout "%sysfunc(getoption(WORK))/file.xlsx";

%let server=http://yourserver.company.com:7980/SASContentServer;

proc http  
url="&server./repository/default/sasfolders/Shared%20Data/stp_samples/file.xlsx"
  WEBUSERNAME="xxxxx"
  webpassword="xxxxx"
  method="GET"
  OUT=xlsout
;
run;

proc import datafile=xlsout
 out=result
 replace
 dbms=xlsx;
run;
Occasional Contributor
Posts: 10

Re: Read Excel file from metadata

Thank you for your help. It works great.
Esteemed Advisor
Posts: 5,198

Re: Read Excel file from metadata

Well if you have the add in, why use Excel format for storage?
The addin could access a SAS data set on the server. That should be registered in meta data, and then easily accessed from DI Studio.
Data never sleeps
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 9 replies
  • 594 views
  • 1 like
  • 5 in conversation