SAS programmers usually lose a lot of time (and temper) when setting up a correct environment before submitting a program. For example, every time you run a program, you need to close all the datasets that are created in the program, clear the log and output windows, save the program etc. Then once the program is run, you need to open a specific dataset to check the results. In a nutshell, you always follow some fixed, time-consuming processes, before and after executing the program.
Before knowing about the DM (Display Manager), I used to say, "if only all this could be done automatically". Then DM statements came to my rescue. A DM statement stands for Display Manager Statements. It submits SAS Program Editor, Log, Procedure Output or text editor commands as SAS statements. This paper will explain the purpose, functionalities and usage of DM statements using several examples.
The intended audience is all levels of SAS users.
2.INTRODUCTION
While coding and executing the code, many redundant tasks are to be done manually. DM statements really prove to be a boon to avoid such redundancies. To date, there is no proper reference paper or document that highlights the power of DM statements. This paper aims to familiarize you with the intricacies of DM. It includes commands for you to play and automatize your chores. Happy Coding!!
3.SYNTAX
DM <window> 'command(s)' <window> <CONTINUE>;
| window: | Specifies the active window. (like wedit, log, output) |
| command: | Can be any windowing command or text editor command and must be enclosed in single quotation marks. If you want to issue several commands, separate them with semicolons. (like wedit, log, output). (like clear, wpaste etc) |
| CONTINUE | Causes SAS to execute any SAS statements that follow the DM statement in the Program Editor window and, if a windowing command in the DM statement called a window, makes that window active. |
The default is the editor window through which you submit the code. This example would clear the concept of the term <window> and <CONTINUE> as used in the syntax. Let’s understand it with the help of the log clear statement. For example:# If you want to clear the log and return back to the editor window after submitting DM statement then:
- Dm log ‘clear;’;
# Else if you want to remain at the log window then
- Dm log ‘clear;’ continue;
# If you want to clear the log and output both, and then return to log window, then
- Dm ‘log; clear; output; clear;’ log;
1) Now, each time you run or debug the code, you have to save the code, clear the log and output, close the open datasets, run them, then search the library for the dataset you are working and open it. Imagine the time and clicks you save using the following code:
- dm 'flsvlast'; *saves the program;dm 'log; clear; output; clear;'; *clears log and output; dm 'next VIEWTABLE:; end;'; *closes the open dataset;
2) If the name of the dataset created is dynamic then you can use the following, which opens the last created dataset.
- dm “vt &syslast";
3) Usually when you are working with a dataset, you want to see the column names and not the column labels. The following statement helps view the column names for a specific dataset, but for other datasets, column labels would be visible.
- dm "VT libname.dataset COLHEADING=NAMES" continue;
4) If you are adding a column to the dataset, or changing the attributes of a dataset, then you are not really interested in the entire data but just the columns and its attributes. The following command will open the column attribute window of the desired table, and not the table.
- dm 'var libname.dataset;' continue;
5) To clear a cluttered results window:
- dm 'odsresults' clear ;
4.CONCLUSION
SAS has unlimited power in many of its unusually used statements. Rather then using the conventional methods, unraveling the mystery behind those statements could unleash newer and more expedient coding standards.
补充内容 (2013-11-3 17:09):
原文出自:http://www.clinovo.com/userfiles ... S-DM-Statements.pdf



雷达卡



京公网安备 11010802022788号







