09-24-2012 12:31 PM
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.
09-24-2012 12:38 PM
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.
09-24-2012 12:53 PM
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.
09-25-2012 02:30 AM
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.
09-26-2012 01:01 PM
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:
SalesPerStore = Sales / Stores;
format SalesPerStore Dollar12.;
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.
09-25-2012 07:13 PM
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