BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ffgsdf
Obsidian | Level 7

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.

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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

6 REPLIES 6
FreelanceReinh
Jade | Level 19

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.

ffgsdf
Obsidian | Level 7

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

FreelanceReinh
Jade | Level 19

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(...);)?
ffgsdf
Obsidian | Level 7

Hi, 

 

 

 

 

 

 

 


未命名的圖片.png
FreelanceReinh
Jade | Level 19

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.

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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