BookmarkSubscribeRSS Feed
Ivan_Vovkanych
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!

3 REPLIES 3
Rick_SAS
SAS Super FREQ

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.

Ivan_Vovkanych
Fluorite | Level 6

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.

 

 

Rick_SAS
SAS Super FREQ

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.

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1293 views
  • 0 likes
  • 2 in conversation