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.