05-29-2013 11:02 AM
I would like to email the contents of the current program editor window. Is this possible? (This is to send jobs to a remote processing system that only receives jobs via email).
05-29-2013 04:57 PM
In the DMS Enhanced Editor, if you do File-->Send Mail, a new message window opens with your current program attached as a txt file (at least in Windows). Does that work for you?
If, on the other hand, your program needs to be the actual body of the e-mail message instead of an attachment, I don't think there's a point-and-click way to do that. You could, of course, save your program, then write another program which reads your program back in as text, and sends it using "filename email".
05-30-2013 03:13 AM
Unfortunately the program needs to be in the body of the email. Saving the file then reading it back as text sounds feasible. Can someone give me pointers on how to start such a program running and how to automate display commands such as saving the editor window to a temporary file? I know SAS macro but don't have any experience automating the editor.
05-30-2013 10:01 AM
I confess I'm a little confused. Your original posting indicated you had a program in the program editor. How did it get there? If you typed it in, or copy/pasted from another source, then just hit the "Save" button or type "flsvlast" into the command line. If it's already saved somewhere with a ".sas" extension, then you don't need to open it up in the editor at all. A ".sas" file is plain text. You just need a program to open it as text, read it in, and "put" the contents to the output destination with "filename email".
There's no reason I can think of for "automating the editor". Am I missing something?
05-30-2013 10:16 AM
Karl, the scenario is basically as you describe. I have the program open in the editor and am testing it on my local machine. When it is ready to go, I want to type something on the command line (or choose a menu item or button) which will then start a program which
1) finds out which sas file I currently have open
2) saves it (sounds like flsvlast is the command I need for this)
3) runs another SAS program which reads the file back in and sends it to email.
So step 1 requires some 'automating'.
I'm also pondering how to do step 3) because I can't use MAPI (I'm using SAS 64 and Office 32) and I don't seem to have access to a simple SMTP server - my university SMTP server requires STARTTLS.
05-30-2013 11:12 AM
I'm still curious as to how the program gets into the editor, but anyway:
1) assuming you're using the enhanced editor, the environment variables SAS_EXECFILENAME and SAS_EXECFILEPATH contain the name and the full path respectively of the currently running program. You'd use the %sysget() function to return those values to your program. I realize that what you really want is the fully-qualified name of the program in the editor window, but I'm not sure how to get that--again, because the program got into the window somehow, so I don't know how you wouldn't now that it's name already.
2) yeah maybe. On the other hand, do you need to save the file at all? Once you have it working in test mode, why not just write a little wrapper program that you copy the contents of the window into. It would turn your program into data, input it basically as a dataset in WORK, and then output it to filename email. Something like;
input program_line $ 1-80; /* big enough for your longest program line */
<paste your program here>
then read myProgram into your email program. It seems to me that you're making it too complicated, but there are pieces of the puzzle I don't know.
3) I might recommend making this step a new thread to get help from somebody better able than I to handle the many details of e-mailing from SAS. I do it all the time, but it took me a while to find the right combination of EMAILHOST, EMAILAUTHPROTOCOL and EMAILSYS that reliably works with my SMTP server. Sorry I can't be more help.
05-30-2013 12:16 PM
Well yes, I do know the name of the program in the editor, but I'm working with several different ones and get easily confused :-)
Re 2), that is an interesting idea, but it is not really any better than cutting and pasting into my email program. I'll do some more exploring on 3) and maybe put up a separate thread.
05-31-2013 12:27 AM
I find it much easier to automate the original program editor (instead of the "enhanced" editor). You can create command line macros to automate the steps. But it would still be difficult to prevent it from losing the name of the file that SAS thinks you are editing (not that I trust SAS to remember the name of the file I am editing as it has a nasty habit of thinking I am editing the file that I just pulled in to copy some code from).
%macro xx /cmd ;
gsub 'filename code temp;' ; file code ; gsub 'data _null_; infile code; input; list; run; filename code clear' ;
You could replace the data _null_ step with code to copy the file to proper email address. You could even map the command macro to a function key or icon on the toolbar.
05-30-2013 12:37 AM
If you save the contents of the enhanced editor we can send the contents as an attachment to the mail. If yes pls reply i will give the code send mail as an attachment.
05-30-2013 08:02 PM
I don't do anything as elegant as creating a macro. To preserve the formatting and color coding of the Enhanced Editor, I simply copy the part of the code that I want to include in my email and paste it into MS Word then copy it from MS Word and paste it into my email. I use Outlook but I assume that most current email software will handle the text similarly.
Clunky and inelegant -- but simple and relatively fast.