08-20-2012 03:11 PM
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).
08-20-2012 04:37 PM
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.
08-20-2012 10:54 PM
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 .
08-23-2012 08:34 AM
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.
08-21-2012 04:20 PM
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;
SAS creates the data set SALESDATA when it executes the stored compiled program STORED.SALESFIG.
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.
08-23-2012 08:19 AM
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.
08-23-2012 12:10 PM
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 ;