Help using Base SAS procedures

How to packup a SAS program

Reply
Regular Contributor
Posts: 222

How to packup a SAS program


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

Respected Advisor
Posts: 3,799

Re: How to packup a SAS program

Posted in reply to Mike_Davis

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


Super User
Posts: 3,250

Re: How to packup a SAS program

Posted in reply to data_null__

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.

Super User
Posts: 10,018

Re: How to packup a SAS program

Posted in reply to Mike_Davis

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

Respected Advisor
Posts: 3,156

Re: How to packup a SAS program

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

Regular Contributor
Posts: 222

Re: How to packup a SAS program

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

Respected Advisor
Posts: 4,173

Re: How to packup a SAS program

Posted in reply to Mike_Davis

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.

Super User
Posts: 3,250

Re: How to packup a SAS program

Posted in reply to Mike_Davis

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.

Contributor
Posts: 66

Re: How to packup a SAS program

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.

Super User
Super User
Posts: 7,039

Re: How to packup a SAS program

Posted in reply to Mike_Davis

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

User
Posts: 1

Re: How to packup a SAS program

Posted in reply to Mike_Davis

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. 

Ask a Question
Discussion stats
  • 10 replies
  • 990 views
  • 1 like
  • 9 in conversation