BookmarkSubscribeRSS Feed
divyansh
Calcite | Level 5

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

6 REPLIES 6
TomKari
Onyx | Level 15

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

divyansh
Calcite | Level 5

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.

LinusH
Tourmaline | Level 20

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
divyansh
Calcite | Level 5

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

TomKari
Onyx | Level 15

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

FriedEgg
SAS Employee

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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 4233 views
  • 0 likes
  • 4 in conversation