BookmarkSubscribeRSS Feed
Mike_Davis
Fluorite | Level 6


Hello everyone,

I am use SAS base,and I have a SAS program named "mysascode.sas",

I wonder is that possible to create  an executable file (its name is "mysascode.exe"(file's extension is .EXE)) from this SAS code?

So when I run the .EXE file it will has the same functionality as I open SAS console and run "mysascode.sas",

But the difference is the .EXE file will not show the content of the SAS code(hide the code).

Thanks

Mike

10 REPLIES 10
data_null__
Jade | Level 19

Don't hide code.  This is SAS programming not espionage.


SASKiwi
PROC Star

My guess is you are comparing SAS to a "compile and run separately" language like Visual BASIC. SAS is an interpretive language where compilation if necessary and execution take place at the same time when a program is run. You can compile DATA steps individually (check out the documentation) but in my experience this is not widely used as there are few benefits as well as disadvantages. FYI SAS procedures are already partly compiled processes to which you pass parameters.

The main reason for packaging SAS would be to make it easier to distribute pre-built SAS applications that cannot be changed - SAS tends not to be used this way and in any case the SAS architecture doesn't lend itself to this type of approach.

Ksharp
Super User

A workaround is using .bat file if your OS is WIN, while using .sh if your OS is UNIX . including the following code in it:

c:\sas9.2\sas.exe -sysin c:\temp\mycode.sas

Double click this .bat file .

Ksharp

Haikuo
Onyx | Level 15

I believe OP wanted something different: 1) standalone executable ( without SAS) 2.Code is encrypted after compilation. Haikuo

Mike_Davis
Fluorite | Level 6

Hi Haikuo,

I want to do something like the second ,I have some calculation part of SAS code don't want to be show up.

Thanks

Mike

Patrick
Opal | Level 21

I agree with data _null_   - but let's assume you really need to hide the code.

There is a secure option for macro compilation http://support.sas.com/techsup/technote/ts739.pdf

"I have some calculation part of SAS code don't want to be show up."

Eventually creating your own functions with PROC FCMP would give you what you want.

SASKiwi
PROC Star

In that case there are options you can explore:

1) If your code is just in a DATA step then you can compile the code and just supply/use the compiled program without the source code like so:

The first DATA step produces a stored compiled program named STORED.SALESFIG:

libname in 'SAS-library-1 ';

libname stored 'SAS-library-2 ';

data salesdata / pgm=stored.salesfig;

   set in.sales;

   qtr1tot=jan+feb+mar;

run;

SAS creates the data set SALESDATA when it executes the stored compiled program STORED.SALESFIG.

data pgm=stored.salesfig;

run;

2) If your program consists of more than DATA steps you can store the entire program in a SAS macro, compile the macro and supply/use the compiled macro only without the source code. Check the SAS macro documentation for this approach. You may have to add SAS options like NOSOURCE to avoid SAS statements appearing in the log.

3) One other option would be to use SAS/AF if you have it licensed and put your SAS program into a compiled SCL program, controlling what shows in your log with NOSOURCE. I just mention this for completeness, as I wouldn't recommend learning SAS/AF and SCL just for this one problem. The learning curve is pretty steep.

CameronLawson
Obsidian | Level 7

I have to agree with data _null_, all things considered what is the actual benefit of hiding the SAS program?

If you really need to then one way is to execute the code via Java, .net etc. and create an executable for that.  Look for support documentation for Integration Technologies which have a number of cookbooks on the subject.  In java, at it's most simplest, using exec() would work.  A better scenario is to utilise the iom and workspace providers.

Tom
Super User Tom
Super User

What I have done when I needed to use small SAS programming inside of operating system script is use the -STDIO option and embed the SAS code in the script.  You could probably figure out how to do something similar in a compiled language like C.

> more runsas

sas -noautoexec -noterminal -stdio <<ENDCODE

proc print data=sashelp.class ;

run;

ENDCODE

Analyst_Amulya
Calcite | Level 5

Hi Mike_Davis,

 

Was your issue solved. I'm facing a similiar issue - to create an executable file without showing the contents of the code. 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 10 replies
  • 3028 views
  • 1 like
  • 9 in conversation