BookmarkSubscribeRSS Feed
Fluorite | Level 6

Hello everyone,

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?


Thank you!


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

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.

Fluorite | Level 6

Thank you Rick,

I would like to calculate poisson binomial distribution cdf.
Actualy this is one topic :


ps. Unfortunately step 2 will not work for us because not always might use client Windows PC.




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.




Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 3 replies
  • 2 in conversation