call compiled c script using SAS

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

call compiled c script using SAS

Hi,

 

I am trying to call a compiled c program using SAS. The c script was compiled using VS. Does anyone know how to do that? so that I can execute the c syntax in a do loop. 

 

Many thanks!!

 

C.


Accepted Solutions
Solution
‎02-02-2017 02:55 PM
Super User
Super User
Posts: 7,682

Re: call compiled c script using SAS

This compiled program, is it compiled to an EXE?  If so then you call that via your OS using X command or %sysfunc().  If its compiled to something else, a DLL or something then it will be different.

 

 

View solution in original post


All Replies
Super User
Posts: 19,038

Re: call compiled c script using SAS

Solution
‎02-02-2017 02:55 PM
Super User
Super User
Posts: 7,682

Re: call compiled c script using SAS

This compiled program, is it compiled to an EXE?  If so then you call that via your OS using X command or %sysfunc().  If its compiled to something else, a DLL or something then it will be different.

 

 

Occasional Contributor
Posts: 8

Re: call compiled c script using SAS

It's compiled as an EXE and called by SAS for execution. 

 

I realized that there are other options for compiling the script file such as DLL, and the DLL can be used by SAS with combination to Proc FTP.

 

Lots of options...for a newbie to C and VS. 

 

Thanks everyone!

Super User
Posts: 7,393

Re: call compiled c script using SAS

If it is something you can call from the commandline, you can use it as argument in a system() function call or in the call system() subroutine in a data step.

Caveat: you cannot run an executable on your desktop from SAS code that runs on a remote workspace server (SAS Studio or Enterprise Guide with a remote SAS server).

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Valued Guide
Posts: 2,177

Re: call compiled c script using SAS

I regret the passing of my access to SAS on z/os.
Running pre-compiled programs worked so neatly.

PROC FTP ;
RUN ;
Replacing FTP with the relevant program name.

Ok that program had to be able to be found in one of the paths that the op.sys would search.
Given that, input and output files also needed to be pre-assigned with FILENAME statements.
Integration with SAS was so good you would imagine this program was a part of SAS - system messages appearing in the SASlog along with a NOTE: like
NOTE: Procedure FTP completed.

The system option NOPROC was supposed to disable this simple flexibility but somehow it was never switched on .

different days

Super User
Posts: 7,393

Re: call compiled c script using SAS

To catch the output from external commands to the SAS log, use filename pipe:

 

filename oscmd pipe "command 2>&1";

data _null_;
infile oscmd;
input;
put _infile_;
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 148 views
  • 5 likes
  • 5 in conversation