SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

sas with php

Reply
New Contributor
Posts: 3

sas with php

Can anyone provide me with a doc telling how to integrate sap with php or is there a sample code that I can refer to see how the integration is done.I am using php and mysql and I need sas for some statistics too.

Thanks,

Divyansh

PROC Star
Posts: 1,167

Re: sas with php

If you need to use SAS to perform statistical operations on MySQL data, you can use the SAS/Access product to retrieve the data from MySQL, and you can just run SAS as a batch program from PHP. Your SAS code would be in a text file that you would refer in your SAS invocation.

If you can provide more details of what you need to do, we can provide more advice. In particular, the hardware / OS that you are running this on would help.

Tom

New Contributor
Posts: 3

Re: sas with php

i need to create a system where i ll b executing queries where data is in mysql but in certain queries I need some statistics,so I was thinkin if I can use sas to perform those statistics,so thats y i am lookin to integrate it with php,so m lookin for some documentation on how to do it or a sample code.

Super User
Posts: 5,429

Re: sas with php

Perhaps it can be done, but it woulnd't certainly be best practice. As TomKari mentioned, running SAS programs on MySQL via the SAS/ACCESS interface is the preferred option.

Data never sleeps
New Contributor
Posts: 3

Re: sas with php

can i get to see any documentation on how this can be done or a sample?

PROC Star
Posts: 1,167

Re: sas with php

To do this without a high level of integration, there are two steps.

The first is to ensure that your SAS software on your server can successfully access your MySQL data. This is done using the SAS/Access product, either the MySQL or the ODBC options. This is completely independent from PHP, and will allow your SAS programs to use MySQL data.

Once this is working, you need to create your SAS code (which can be done dynamically), save it in a text format dataset, and call SAS from PHP, referencing your SAS code. I'm not a PHP programmer myself, but from a quick look at the documentation it appears the exec() function would be ideal for this. On my PC, to execute SAS and have it run a program stored in "C:\SAS_PROGRAMS\TestProgram.SAS", I run the following command under Windows:

"C:\Program Files\SASHome\SASFoundation\9.3\sas.exe" -SYSIN C:\SAS_PROGRAMS\TestProgram.SAS -CONFIG "C:\Program Files\SASHome\SASFoundation\9.3\nls\en\sasv9.cfg"

As a demonstration, my program (TestProgram.SAS) looks like this:

data sasuser.test_output;

set sashelp.shoes;

SalesPerStore = Sales / Stores;

format SalesPerStore Dollar12.;

run;

You would probably substitute a MySQL library for my use of sashelp, and you might send your output to a text file instead of a SAS dataset, but those changes are very easy.

I don't believe that you'll find any major problems, but I'm sure there will be a couple of bumps in the road. Just post your questions back to this discussion board; there's a LOT of expertise reading it.

Good luck,

Tom

Trusted Advisor
Posts: 1,301

Re: sas with php

To integrate with external programming languages you will require SAS Integration Technologies Software.  Through that software you can integrate with SAS in any of several ways including IOM.  PHP is not a very common choice for integration but there should be no limitations other than lack of langugage specific examples in the documentation and fewer outside resources online to help you...

If your plan is to interface through PHP with SAS to exchange data from a MySQL database into SAS you would be far better off enabling SAS to access the data in MySQL directly as others suggested using the appropriate SAS/ACCESS product.  There is one specific for MySQL and there is also the more general ODBC / OLE DB providers

SAS Integration Technologies

SAS/ACCESS

SAS/ACCESS Interface to MySQL

SAS/ACCESS Interface to ODBC

SAS/ACCESS Interface to OLE DB

Ask a Question
Discussion stats
  • 6 replies
  • 1724 views
  • 0 likes
  • 4 in conversation