BookmarkSubscribeRSS Feed
JI9
Calcite | Level 5 JI9
Calcite | Level 5

Is there any way for SAS to read HDF5 files?

5 REPLIES 5
LinusH
Tourmaline | Level 20

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
jakarman
Barite | Level 11

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

---->-- ja karman --<-----
JI9
Calcite | Level 5 JI9
Calcite | Level 5

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.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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/

JI9
Calcite | Level 5 JI9
Calcite | Level 5

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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 4999 views
  • 6 likes
  • 4 in conversation