BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
marty1885
Fluorite | Level 6

Hi all.

 

I'm new to SAS but have been using other analysis tools for a while.

 

I have been analysing data using ROOT and all of my data is stored in ROOT's TTree format. Recently I'm tasked to export some of my data for statisticians whom use SAS primarily. Are there better way to exchange data between the two frameworks? CSV and JSON are not a viable option as they are huge and clunky. Also, what would be a good way to get data from SAS back into ROOT?

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

A quick google search found at least one example of a program to convert Root TTree file into CSV file.

https://root-forum.cern.ch/t/root-tree-to-csv-file-format/27633/3

 

If you can get that to run then in SAS you can just use the PIPE engine to run it on the fly.

data want;
  infile 'root2csv -f myrootfile' pipe dsd truncover ;
  ...
run;

View solution in original post

7 REPLIES 7
Kurt_Bremser
Super User

I can't think of anything more compact than a gzip'ed csv file for data transfer. Supply a documentation of the structure along with the file, so that the recipients can exactly recreate the data.

SAS can read a gzip'ed csv file in one action like this:

filename ziptest zip 'class.csv.zip'; /* insert the path where you stored the file */

data class;
infile ziptest dlm=',' dsd;
input
  name :$8.
  sex :$1.
  age
  height
  weight
;
run;

The file was created with

data _null_;
file ziptest dlm=',' dsd;
set sashelp.class;
put name sex age height weight;
run;

and the end result of the first piece of code will be an exact replica of the SAS demo dataset SASHELP.CLASS.

 

PS I used zip as a file format as the forum software does not allow uploading a .gz file.

The zip compression results in 348 bytes, the gzip gives you 248. Change the filename statement to

filename ziptest zip '$HOME/sascommunity/class.csv.gz' gzip;

to use gzip compression.

marty1885
Fluorite | Level 6

Maybe some context can help. Now, I have a ~100GB compressed ROOT archive which contains a lot of observation (event in root terms) and 50 variables (branch in root terms) per observation from an physics experiment. And from experience and rough math, I'm expecting a 1TB JSON or a 400GB CSV file if I de-compress my root archive. And my college, the statistician's job is to go through these few hundred million observations and find the outliers, then append statistics to each observation so I can find malfunctions in the equipments.

 

So, here's the problem. As he primarily uses SAS, he needs a way to import all my data in ROOT into SAS. But JSON is obviously nonviable and CSV doesn't scale (I need to generate the CSV then compress it). The opposite problem of sending data from SAS to ROOT is also a big one.

Ksharp
Super User

100G is too big for ACCESS file. Using CSV as Tom suggested.

marty1885
Fluorite | Level 6

I think the document is referring to Accessing Data not Microsoft Access

 

Data saved into one or several ROOT files can be accessed from your PC, from the web and from large-scale file delivery systems used, for example in the GRID.

Tom
Super User Tom
Super User

A quick google search found at least one example of a program to convert Root TTree file into CSV file.

https://root-forum.cern.ch/t/root-tree-to-csv-file-format/27633/3

 

If you can get that to run then in SAS you can just use the PIPE engine to run it on the fly.

data want;
  infile 'root2csv -f myrootfile' pipe dsd truncover ;
  ...
run;
marty1885
Fluorite | Level 6
Thank you! This looks like the solution I need.

Is communication in the opposite direction possible? Can SAS output it's data into stdout?

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 1119 views
  • 1 like
  • 4 in conversation