tags:

views:

544

answers:

2

Is there a programmatic way of compiling SAS 9.1.3 SCL code (N.B. not ordinary SAS code) in Windows? The only way I have found of doing it involves using the SAS GUI: we have a Perl script which sends keystrokes to the UI. While this works (sort of), it's ugly and error-prone, and is too fragile to add to our automated build script.

EDIT: My original question was probably somewhat unclear. I am aware of proc build; my problem is getting some plain text into the SAS catalogue as an SCL entry in the first place.

+3  A: 

I found this to be a chicken-and-egg kind of problem. I found that it is only possible to get plain text into an SCL entry, by using an already existing SCL entry...

I have a setup, where I read and write SCL code in Catalog entries, from and to plain text files. I use this for revision control purposes (CVS).

While CVS is mostly used for plain text code, it can also handle binary files. Thus I have made an SCL entry (called FILE2SCL), that can import plain text into other SCL entries. I have then PROC CPORT'ed this SCL entry to a binary file, and checked it into CVS.

This way, I can always programmatically fetch this SCL entry from the CPORT file, and use this SCL entry to import SCL code from plain text into other SCL entries. Afterwards I can use PROC BUILD to compile the SCL entry, exactly like you mention yourself.

My FILE2SCL entry looks like this:

INIT:
  /***************************************************************/
  /*                                                             */
  /* Call this SCL like this:                                    */
  /* %let srcFile=D:\work\dummy.scl;                             */
  /* %let dstEntry=WORK.NEW.DUMMY.SCL;                           */
  /* proc display catalog=work.cat.file2scl.scl;                 */
  /* run;                                                        */
  /*                                                             */
  /***************************************************************/

  length Rc           8;
  length theFile  $ 200;
  length theEntry $ 128;

  theFile=symget('SRCFILE');   * Source file *;
  theEntry=symget('DSTENTRY'); * Destination entry *;

  * Assign filename *;
  Rc=filename('temp',theFile);

  * Include external file into preview buffer *;
  Rc=PREVIEW('INCLUDE','temp');
  * Save contents of preview buffer to SCL entry *;
  Rc=PREVIEW('SAVE',theEntry);
  Rc=PREVIEW('CLEAR');
  Rc=PREVIEW('CLOSE');

  * Deassign filename *;
  Rc=filename('temp','');
return;

The comment explains how to use it: Start with setting a SAS macro variable, "srcFile", to contain the path to your SCL source code file, and another macro variable, "dstEntry" to contain the entry-path to where you want your SCL entry to be. Then PROC DISPLAY the FILE2SCL entry, and it will import your SCL source code into the specified SCL entry, and you can then compile it afterwards by using PROC BUILD.

Martin Bøgelund
A: 

Also, you can possibly check out using Eclipse and the ESLink plugin. It was designed specifically for this purpose (keeping SCL code in regular files for version control with the capability to compile into a catalog).

Jay Stevens