Published on :
Macro MIXTE

Macro to display a dataset

This code is also available in: Deutsch Español Français
This macro, named `AHGdisplayprint`, aims to display a SAS© dataset. It takes the name of the dataset to print as an optional parameter. If no name is provided, it will act on the last created dataset (`_LAST_`). The display is formatted to not show observation numbers (`noobs`) and to use the minimum width for columns (`width=minimum`), making the output more compact.
Data Analysis

Type : MIXTE


The macro does not create data by itself. It is designed to read and display a dataset that must exist at the time of its execution. This dataset can come from any source (internal creation, SASHELP libname, external source) and must be specified via the `data` parameter or be the last active dataset.

1 Code Block
PROC PRINT
Explanation :
This block defines the `AHGdisplayprint` macro. It uses a `%if %length(&data)` statement to conditionally add the `data=` parameter to `PROC PRINT`. If the macro is called without a parameter (`%AHGdisplayprint()`), `PROC PRINT` will execute on the last created dataset. Otherwise, it will execute on the dataset passed as a parameter.
Copied!
1%macro AHGdisplayprint(DATA = );
2 PROC PRINT
3 %IF %LENGTH(&DATA) %THEN
4 %DO;
5 DATA = &DATA
6 %END;
7 noobs
8 width = minimum
9 ;
10 RUN;
11%mend ;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : A Revision Control System (RCS) header was detected, indicating the author, revision date, and modification history. Author: liux43, Date: 2010/04/19.