Read HDF5

Reply
New Contributor JI9
New Contributor
Posts: 3

Read HDF5

Is there any way for SAS to read HDF5 files?

Super User
Posts: 5,260

Re: Read HDF5

By looking at the file specification, I would advise to look for an alternative way rather then trying to import it using something like INFILE.

What system/SW produced the file?

Perhaps they offer an API, like a JDBC driver.

Data never sleeps
Valued Guide
Posts: 3,208

Re: Read HDF5

Agree with Linus, when you find a program (phyton?) there could be a way to integrated using Xcmd.   XCMd is available? 

---->-- ja karman --<-----
New Contributor JI9
New Contributor
Posts: 3

Re: Read HDF5

There is an export tool in the HDF5 application that will output csv files.  And R has a package that reads HDF5.  But we still use SAS for data management and I was hoping to avoid the intermediary steps.  Jaap is right, though, I could use XCMD to call a Python or R routine.  Thank you for your help.

Super User
Super User
Posts: 7,413

Re: Read HDF5

There is a dump tool which will export the file to XML/ASCII if that helps:

HDF5/Tools API Specification

From: http://www.hdfgroup.org/HDF5/XML/

New Contributor JI9
New Contributor
Posts: 3

Re: Read HDF5

Yup, I believe that is the program R calls as part of the R package rhdf5.  The solution I've settled on is calling the h5dump function in R (which in turn calls the h5dump tool you linked to, I think) from Proc IML.  The bit64 package is also used because, at least in my case as I'm running 32-bit SAS 9.4, integer64 data types are created in R from the HDF5 files.  SAS does not recognize the integer64 data type on SAS 9.4 32-bit, maybe 64-bit would work.  Since I am getting integer counts from instruments, I was able to safely convert the integer64 data to regular integers before importing into SAS. Anyway, here is the code I've used and it appears to work.

proc iml;

submit / R;

library(rhdf5)

x <- h5dump("c:\\data\\Counts.h5",bit64conversion='bit64')

s <- do.call(cbind,x$Hist)

ss <- as.integer.integer64(s)

endsubmit;

run ImportMatrixFromR(ss,"ss");

*** Create data set work1 from the IML matrix ss. ***;

create work1 from ss;

append from ss;

close work1;

quit;

Ask a Question
Discussion stats
  • 5 replies
  • 957 views
  • 6 likes
  • 4 in conversation