10-20-2015 07:42 AM - edited 10-20-2015 07:43 AM
I use a C code to create a subroutine (using proc proto and proc fcmp). The problem is that it uses a vector as a parameter and creates a vector as a result. This looks problematic in data step of BASE SAS, but I thought SAS IML might work out way better. Does anyone have a clue how to use a SAS routine in SAS IML? Or anyone knows a way how to make this work in a data step?
10-20-2015 09:31 AM
I've never done this in PROC IML, but I have three comments:
1) SAS/IML uses the MODULEI (return void), MODULEIN (return number), and MODULEIC (return char) subroutines to call DLLs that contain C functions. You can pass in vector and matrices for arguments.If you mark an argument as 'update', then the C routine can change the values of the argument (like passing a pointer). I think this is what you want to do.
2) Although I have never done (1), I have called C DLLs from the SAS/IML Studio application, which has a much simpler system for calling DLLs. See the documentation for "Extending IML"-->"UIsing C" at http://support.sas.com/documentation/onlinedoc/imlstudio/WebHelp132/root.htm
3) I have found that well-written vectorized IML code is almost as fast as C code for many applications. You might want to post what you are trying to accomplish. Someone might have IML code that does it already.
10-20-2015 09:41 AM - edited 10-20-2015 09:56 AM
Thank you Rick,
I would like to calculate poisson binomial distribution cdf.
Actualy this is one topic : https://communities.sas.com/t5/SAS-Statistical-Procedures/Poisson-binomial-distribution-in-SAS/m-p/2...
ps. Unfortunately step 2 will not work for us because not always might use client Windows PC.
10-20-2015 10:06 AM
Hmm, not for the faint of heart! Have you looked at the FFT function in SAS/IML? I think IML has the building blocks that you need, but that's not a trivial computation. I do not know which method would be easier: calling a C routine or rewriting in IML. I guess if you have a working and debugged C routine, that is the method you should try first, but I am not finding any good examples that lay out all the steps for calling C functions from PROC IML. I guess you'll have to use the examples for the DATA step versions such as CALL MODULE.