DATA Step, Macro, Functions and more

open a program everytime SAS lauches

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
Accepted Solution

open a program everytime SAS lauches

If i have a program whose pathway is "C:\SASMACRO\WISC4.sas"

 

How could I automaticly load it in sas everytime I start to use SAS.


Accepted Solutions
Solution
‎04-28-2016 10:46 AM
Trusted Advisor
Posts: 1,115

Re: open a program everytime SAS lauches

Thanks for the clarification. So, it's case A from the list in my previous post. Here are the steps to achieve what you want (assuming a Windows system):

  1. Create a SAS program autoexec.sas containing the following code:
    dm 'whostedit'; /* opens an Enhanced Editor window (optional) */
    dm 'fileopen "C:\SASMACRO\WISC4.sas"'; /* opens your program */
    dm 'wpgm' continue; /* switches the focus back to the empty Enhanced Editor window (optional) */
  2. Save it to the folder where sas.exe resides (typically C:\Program Files\SASHome\SASFoundation\9.4, but please check).

 

Additional information:

SAS searches several locations for autoexec.sas files: please see section "The Default Autoexec File" in Files Used by SAS. So, the above assumes that SAS doesn't find another autoexec.sas in a location with higher priority.

 

On my workstation I use an autoexec file with a different name and in a different location, which is specified in the -AUTOEXEC system option that I apply when launching SAS. I can give you further instructions if you want to go this route instead.

 

View solution in original post


All Replies
Super Contributor
Posts: 305

Re: open a program everytime SAS lauches

you include it in the autoexec file.

 

Here is the documentation :

http://support.sas.com/documentation/cdl/en/hostunx/63053/HTML/default/viewer.htm#p13flc1vsrqwr8n1vu...

 

Trusted Advisor
Posts: 1,115

Re: open a program everytime SAS lauches

Hi @ffgsdf,

 

It is not quite clear from your question whether you want to run WISC4.sas or to open it (in the Enhanced Editor).

 

The good thing is that @Loko's suggestion works for both purposes:

 

The following line in your autoexec.sas (you can name this program differently) will run the program automatically when you launch SAS:

%inc 'C:\SASMACRO\WISC4.sas';

The following line will open the program automatically in the Enhanced Editor when you launch SAS:

dm "fileopen 'C:\SASMACRO\WISC4.sas'";

If this is to make a SAS macro available (as your path name suggests), you may also want to read about autocall libraries.

Occasional Contributor
Posts: 14

Re: open a program everytime SAS lauches

Hi, Loke and 

 

I am sorry to confuse you about my description of question.

 

I want to sas open the  macro I told as a memo because I learn that Rsutdio has this function, too. 

 

I think it is a funcition to remind me and make my write code quicker.

 

I have read the sas auto and the  autoexec file. 

 

however, i failed to do it. 

 

Can you give me the exact code with the example "C:\SASMACRO\WISC4.sas" to help me do it.

 

thx

Trusted Advisor
Posts: 1,115

Re: open a program everytime SAS lauches

Hi @ffgsdf,

 

I would like to write SAS code more quickly, too, but I'm not familiar with RStudio. So, I'm curious what type of code your program WISC4.sas contains. Is it

  • A) a long program or SAS macro that you're currently developing or that you need as a sample program (to copy and paste) and which you want to load into the Enhanced Editor automatically in order to save the repetitive mouse clicks in the "Open Program..." dialog

    or

  • B) a complete SAS program that you want to execute automatically, e.g., to set system options, create work datasets, set macro variables or do whatever you would do otherwise manually in your work environment everyday after starting a SAS session

    or

  • C) a SAS macro (like %macro wisc4(...); ...<macro code>... ; %mend wisc4;) which you want to make available automatically, so that you can call it (like %wisc4(...);)?
Occasional Contributor
Posts: 14

Re: open a program everytime SAS lauches

Hi, 

 

 

 

 

 

 

 


未命名的圖片.png
Solution
‎04-28-2016 10:46 AM
Trusted Advisor
Posts: 1,115

Re: open a program everytime SAS lauches

Thanks for the clarification. So, it's case A from the list in my previous post. Here are the steps to achieve what you want (assuming a Windows system):

  1. Create a SAS program autoexec.sas containing the following code:
    dm 'whostedit'; /* opens an Enhanced Editor window (optional) */
    dm 'fileopen "C:\SASMACRO\WISC4.sas"'; /* opens your program */
    dm 'wpgm' continue; /* switches the focus back to the empty Enhanced Editor window (optional) */
  2. Save it to the folder where sas.exe resides (typically C:\Program Files\SASHome\SASFoundation\9.4, but please check).

 

Additional information:

SAS searches several locations for autoexec.sas files: please see section "The Default Autoexec File" in Files Used by SAS. So, the above assumes that SAS doesn't find another autoexec.sas in a location with higher priority.

 

On my workstation I use an autoexec file with a different name and in a different location, which is specified in the -AUTOEXEC system option that I apply when launching SAS. I can give you further instructions if you want to go this route instead.

 

☑ This topic is SOLVED.

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

Discussion stats
  • 6 replies
  • 361 views
  • 3 likes
  • 3 in conversation