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

 

Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.

 

Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer. 

 

Register now!

From SAS Users blog
Want more? Visit our blog for more articles like these.
5 Steps to Your First Analytics Project Using SAS

For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.

Find more tutorials on the SAS Users YouTube channel.

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