BookmarkSubscribeRSS Feed
craig159753
Quartz | Level 8

Hi, I am trying to use the PROC SQL pass through facility to import a .XML file. Below is an example of something I use for EXCEL files, is there a .XML equivalent?

 

proc sql noprint;
	connect to excel (path = "\\MyArea\My_File.xls");
		create table contents as
		select *
		from connection to excel (select * from [Contents$]);
	disconnect from excel;
quit;

The above code would pick up the tab called "Contents" and create a SAS data set call Contents.

 

Thanks

2 REPLIES 2
Reeza
Super User

What version of SAS are you using?

 

And why do you need SQL Pass Through? Is the file in a Database?

 

The libname method is the suggested method.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

As far as I can tell that is not using pass through.  It is using the libname excel technology.  What libname excel does is setup a SAS library reference to the file, and creates a dataset for each sheet it can find and process, a bit like a proc import for each sheet, with all of the problems associated with importing an Excel file.  It is not pass through.  Pass through is where a set of SQL statements is taken from SAS, and sent to another systems SQL processor, for example:

proc sql;

  connect to oracle (..);

  execute by oracle (select * from abc);

...

The "select * from abc" is sent to Oracle's SQL parser, hence it can use functions and types in the oracle system, and not ones in the SAS system.

 

Now your second question, regarding access to XML.  This is done by map files, you can use the free XMLMapper tool from SAS, but basically you need to provide a "spec" for the XML document, i.e. how the file is supposed to be read into SAS - remember an XML file could have multiple datasets!  Have a look here for example:

http://www2.sas.com/proceedings/sugi29/119-29.pdf

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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