DM Statement
DM Statement
INTRODUCTION
While coding and executing the code, many redundant tasks are executed manually. DM statements 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 lots of commands to play and automatize coding chores. Happy Coding!!
SYNTAX
DM <window> 'command(s)' <window> <CONTINUE>;
window
command
CONTINUE
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. Lets 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';
dm 'log; clear; output; clear;';
dm 'next VIEWTABLE:; end;';
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 'odsresults' clear ;
6) If you are paranoid about using PROC EXPORT and PROC IMPORT, and you just want to do the basic
export/import, then the following DM statement is for you. It works with excel and txt files.
9) At times, in interactive mode, you wish to stop your program from going in an infinite loop, or during
debugging you dont want to run the whole code but a selection, (but dont want to select each time you run).
You can use the following, which will give you a prompt, asking to cancel submitted the code.
data a;
a=1;
run;
data b;
b=1;
run;
For ex:
Dont want to
run both data
steps for
debugging.
Then use as
shown and
answer the
prompt.
data a;
a=1;
run;
dm "WATTENTION";
data b;
b=1;
run;
11) By combining DM commands, you can copy from and paste in a file. For example, if you want to add a
header, or some constant code/text, or copy from one file and paste in other file, the following code can do it
without any user intervention:
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.
CONTACT INFORMATION
Your comments and questions are valued and encouraged. Contact the author at:
Megha Agarwal
CLINOVO
1208 E. Arques Avenue
Suite #114
Sunnyvale, CA 94085
Work Phone: (408) 773-6251
E-mail: [email protected]
Web: http://www.clinovo.com/
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of
SAS Institute Inc. in the USA and other countries. indicates USA registration.
Other brand and product names are trademarks of their respective companies.