Published on :
Macro CREATION_INTERNE

Path Test Macro

This code is also available in: Deutsch Español Français
This macro, named 'testit', is designed to illustrate the behavior of the %SYSFUNC(DEQUOTE) function when processing macro parameters that may contain quotes. It uses a DATA _NULL_ step to display the value of the 'path' parameter in the SAS© log after removing any quotes (single or double). Successive calls to the 'testit' macro demonstrate how SAS© handles character strings, whether passed raw, with single quotes, or with double quotes. This script is useful for understanding character string manipulation in the SAS© macro environment.
Data Analysis

Type : CREATION_INTERNE


The script does not process existing SAS data or create persistent data. It manipulates and displays a literal character string passed as a macro parameter, using only the console (log) for output.

1 Code Block
MACRO DEFINITION & DATA STEP
Explanation :
This code block defines and calls the `testit` macro. The macro takes a `path` parameter. Inside the macro, a `DATA _NULL_` step is used to write directly to the SAS log. The `%SYSFUNC(DEQUOTE(&path))` function is crucial here: it removes quotes (single or double) from the value passed to the `path` parameter before it is displayed. The three subsequent calls to `%testit` show how the `DEQUOTE` function handles different string passing syntaxes (without quotes, with single quotes, with double quotes), ensuring that the result displayed in the log is always the path without quotes.
Copied!
1%macro testit(path=);
2DATA _null_;
3put "%sysfunc(dequote(&path))";
4RUN;
5%mend testit;
6 
7%testit(path=D:\Projects\);
8%testit(path='D:\Projects\');
9%testit(path="D:\Projects\");
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.