Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

SAS Dataset module

by ab1447 (Novice)
on Dec 14, 2005 at 21:42 UTC ( #516774=perlquestion: print w/replies, xml ) Need Help??

ab1447 has asked for the wisdom of the Perl Monks concerning the following question:

Dearest Monks, I am writing a CGI script whose input will be stored in a SAS dataset (work requirement). I realize I can send this input as a text file and run SAS to process the file. However, this requires processing time. Therefore, I would like develop a module (or something) that will allow me to work directly with a SAS datset through perl. Any suggestions on even where to start??? Lost in a maze of SAS. Thanks.

Replies are listed 'Best First'.
Re: SAS Dataset module
by beachbum (Beadle) on Dec 14, 2005 at 22:43 UTC

    I'm not aware of any way to directly read SAS datasets... aren't they stored in a proprietary format?
    That said, I have used thier ODBC Driver along with DBD::ODBC for a similar need.

Re: SAS Dataset module
by BazB (Priest) on Dec 15, 2005 at 12:37 UTC

    Note that my SAS is a little rusty, I've not touched it in about 6 months, and I'm working from memory.

    As a previous poster has said, SAS stores it's data in a proprietary format (however this is irrevelant - I don't read MySQL data directly, so why should I care about SAS?).
    SAS doesn't exactly make it easy to access data from other applications. ODBC is the only means of DBI compatible way of connecting to the database/application that I'm aware of.

    If I remember correctly, it is possible to have SAS read it's input from a pipe; you might what to look at setting up a process that your CGI injects data into to have SAS read it from the other end.

    Another alternative would be to dump the data from the CGI into a database that has a Perl friendly interface that SAS can also access, but frankly that's just introducing other pointless layer and, knowing SAS, more cost.

    To be honest, I've always found that the simplest way is usually the best: if all you need to do is store data in SAS, dumping the data to a file and calling SAS from Perl to process the data (possibly generating the SAS code to do it first) is simple and relatively fast.

    I hope that gives you a few ideas.


    If the information in this post is inaccurate, or just plain wrong, don't just downvote - please post explaining what's wrong.
    That way everyone learns.

      Thank you for all of your input. Until futher notice, I will just use SAS to process a CGI created file. On an unrelated note, I thought that Microsoft Word, Excel, etc were propority formats, yet OpenOffice works with them. So in theory the obstacle of a SAS properity data format is breakable...right?
        There are a number of projects ongoing to reverse engineer the sas7bdat dataset format. One open opensource project that is written entirely in R code can be found at http://biostatmatt.com/R/sas7bdat_0.2.tar.gz This would be easily ported to Perl I would think.
Re: SAS Dataset module
by swampyankee (Parson) on Dec 15, 2005 at 03:20 UTC

    I did a quick search on CPAN and found nothing; I'm sure you've had the same result before you asked.

    The statistics system R has a module to handle "foreign" files, supposedly it can deal with SAS files. (I've never had need to read SAS files; I've had to read SPSS files. Wrong version of SPSS was supported by R's module when I was trying to mung SPSS files). Of course, if you're going to use R, you may as well use SAS, but the module's source code is available, and it or the documentation may give you enough information to do your data filtration entirely in Perl. See CRAN module descriptions.

    Conversely, it may give you enough information to decide to use SAS


    I found out from astaines that this won't work. Sorry for wasting your time

      R can read SAS XPORT files, but not SAS datasets, so it writes a SAS program to convert your dataset to a SAS XPORT format. This format is documented.

      The catch, of course, is that you need a working SAS installation to do this.

      -- Anthony Staines

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://516774]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (1)
As of 2022-05-18 20:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (71 votes). Check out past polls.

    Notices?