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

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
Fluorite | Level 6

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
Fluorite | Level 6

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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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