Is there a way to open my existing sas code files by executing a line of sas code?
I mean, I would like to open three sas code files, let's say code1.sas, code2.sas, and code3.sas. Can I let my sas to open all of them? I know I can open them by dragging to sas or using menu. But I would like to do so via code. Thanks!
Only when you're working with Display Manager:
dm prog "include test.sas";
Use %include.
%include "path-to-program\code1.sas";
Thanks for your comment. I know %include statement, but doesn't it run my code indicated by %include statement, rather than opening it in SAS window? Sorry for not making my question clearer, but I would like to have a code to open my other SAS codes in SAS window so that I can amend them if needed.
@braam wrote:
Thanks for your comment. I know %include statement, but doesn't it run my code indicated by %include statement, rather than opening it in SAS window? Sorry for not making my question clearer, but I would like to have a code to open my other SAS codes in SAS window so that I can amend them if needed.
Assuming you are running SAS using the Display Manager interface then you want to execute the INCLUDE command line statement instead of the %INCLUDE macro statement. You can use the DM command to run Display Manager commands from code. There are other commands for moving focus to the appropriate window, it doesn't work try to INCLUDE a file into the LOG or OUTPUT window.
This is NOT the %include macro statement. It is a command for the Display Manager to load the named file into the program editor.
The necessary commands may look different when using Windows Base SAS, as you can open several Enhanced Editor windows there IIRC.
The command I gave you was tested with Base SAS on AIX.
Open to do what? Open with what?
I would like to have a code to open my other SAS code files in SAS window. Then I can look at my code files (interactively) and amend them if needed. Without this, how I do is to open several files manually whenever I turn on my PC and SAS. Hope that it's clearer.
Seems like a strange request. How do you know what programs you want to open for this SAS session?
You can open many "enhanced" editor windows in PC SAS. You can only have one regular PGM window (on any operating system).
You can also open many NOTEPAD windows, which work a lot like editor windows, but you need to link some SAS catalog source object type.
Here is a good thread about how to find a list of SAS Display Manager commands.
https://stackoverflow.com/questions/1233056/sas-display-manager-commands
Only when you're working with Display Manager:
dm prog "include test.sas";
Thank you so much for your help. Your code worked for me when "wpgm" is used in dm!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
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.
Ready to level-up your skills? Choose your own adventure.