Hi everyone, Please I need help to address integrating SAS into PHP.
I'm trying to integrate SAS code into PHP that can deal with data manipulation using data step, proc sql, it will also use macro, etc. We have the code completed in SAS already, the code also make a macro call to another macro, it calculates Overall Concordance Correlation coeficient based on Barnhart equation, using %include. How can I integrate this existing programs into PHP(We are building an application using PHP).
Thank You.
Can you call external programs using PHP?
PHP is generally running on web servers. Is SAS installed there too?
If not, you'll need to use a remote shell to connect to the SAS server and run a command there. And then recover the result.
Alternatively, you could put the SAS code in a SAS Stored Process and call that. See different discussions about what can be done
https://stackoverflow.com/questions/43254184/sas-connection-with-php
Or even this one where a stored process page is called using Python (but it could be called using any other language)
https://stackoverflow.com/questions/35567259/sas-stored-process-to-a-web-service-link
@JuanS_OCS Thank you very much. These are interesting options.
I'm interested in these options, especially in relation to cost. Are they cost effective?
I'm new to SAS but as a software developer whose done a number of mixed stacks with PHP including Java/PHP I would strongly advise not to mix them directly. Tends to get convoluted and the work required in my experience had poor ROI. The hacks to get Java working in PHP reliably or even calling Java binaries isn't ideal. Calling Python binaries/scripts generally I've found less problematic but still not ideal. Would be better to have the data/tasks distributed through some JSON friendly service (a Rest API basically) or queue service. Probably easiest to do in Python if there is a learning curve involved. Once done it easy to call that service via the web server/PHP.
I have used SAS in ASP.NET and Blazor apps. Same concept should apply for PHP. IMO, you don't need to do bat or any command shell code. They do not scale and are really not integrated into the system. I have had SAS running in hundreds of instances doing web requests.
Ok, how? Using SAS Integration Technologies which should be installed at your site. Here is C# code (full listing here: https://github.com/savian-net/SasDotNetTipsTricks😞
ws = new SAS.Workspace();
var lang = ws.LanguageService;
lang.Submit(code);
Chris Hemendinger has written extensively on using IntTech with various technologies. He may have something on PHP. Basically, use the SAS mechanisms to submit code vs using a shell. A shell should work but a better means is the SAS tech you already have. You can use other SAS means such as Stored Process/Procedure? but IntTech is how it works and also how EG works. Skip the middlemen.
Watch for SAS license constraints for your shop: this is a technical answer only.
Not sure on license impact. Most clients who use SAS already have IntTech licensed due to EG.
I am unsure what you mean about library implementation. What are you referring to? You add the dll, call it, and you are done. The dll is simply the IntTech COM dlls. I do this at every SAS client, pretty much, and have been for decades. Works like a champ.
3 considerations:
There is nothing unusual about this. This is how SAS works in their own products (ex. EG). IntTech has been around, in some form, for decades and it is used to do this integration (code, logs, metadata, etc.). There are plenty of papers on it ranging from VBScript, VBA, C#, etc.
If the concern is that someone will submit malicious code, what I did was just stored the codes files and passed parms in via Swagger or some similar means.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.