Save contents of editor window to a file

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 19
Accepted Solution

Save contents of editor window to a file

Hi,

 

I'm super new to SAS (using SAS 9.4), but have been playing around with some of the features.

 

One of the things that I recently discovered was that I could use ODS to save to PDF and PROC PRINTTO to save a log file to an external file. This got me thinking...is it possible to save the contents of the editor window to a file when you run the script?

 

In my research, I found an article where the author was developing a macro to set up a folder structure, basically to build a common directory and a startup program for research projects. The author used %PUT statements in the macro to write every line of a script to a file.

 

While I found this interesting, I'm looking for something like this pseudo code:

 

PROC PRINTTO editor="C:\MyScript.sas" new;
RUN;

I want to define a path in my script where the script will be stored and have it save to that directory every time I run the script, overwriting any changes if the script already exists.

 

Is this possible in SAS without printing each line of the script in a macro or otherwise?

 

Thanks.


Accepted Solutions
Solution
‎09-28-2016 10:49 AM
Super User
Posts: 10,594

Re: Save contents of editor window to a file

I'd try display manager commands, like

dm 'file "filename"';

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

View solution in original post


All Replies
Solution
‎09-28-2016 10:49 AM
Super User
Posts: 10,594

Re: Save contents of editor window to a file

I'd try display manager commands, like

dm 'file "filename"';

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 19

Re: Save contents of editor window to a file

Posted in reply to KurtBremser

That's perfect. If the file is new, it updates the name in the editor window.


For others that may want to try this, here's the code I used to test:

 

%LET path = C:\Temp;
%LET scriptName = &path.\ScriptTest.sas;

DM 'FILE "&scriptName"';

Once I combine this with my macro to test for the existence of the directory where I want to store the scripts, I'll be in business.

 

Thanks for your help, Kurt.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 368 views
  • 0 likes
  • 2 in conversation