Published on :
Macro SASHELP

AHGtran Macro - Data Preparation and Iteration

This code is also available in: Deutsch Español Français
Awaiting validation
This script defines the `%AHGtran` macro. Its purpose is to isolate variables (`var`, `colvar`, `ordvar`) from a source table (`dsn`) into a temporary table (whose name is generated by `%AHGgettempname`). Once the table is prepared, it calls another macro, `%AHGfreeloop`, to perform iterative processing (likely transposition or dynamic code generation). The script includes an example call on `sashelp.class`.
Data Analysis

Type : SASHELP


The execution example uses the standard `sashelp.class` table. The macro is generic and can accept any SAS table as input.

1 Code Block
DATA STEP Data
Explanation :
Macro definition. It encapsulates a Data Step to reduce the input table to only the necessary variables, then calls the `%AHGfreeloop` macro for processing.
Copied!
1%macro AHGtran(dsn,var,colvar,ordvar,colOrd=,out=);
2 %local thedsn;
3 %AHGgettempname(thedsn);
4 DATA &thedsn;
5 SET &dsn;
6 keep &var &colvar &ordvar;
7 RUN;
8 %AHGfreeloop(&thedsn,&colvar
9,cmd=put
10,out=outAhuige
11,in=Ahuige
12,url=vxwmc
13,execute=1
14,del=1
15,addloopvar=0);
16%mend;
2 Code Block
MACRO CALL
Explanation :
Invocation of the `AHGtran` macro using the `sashelp.class` table, with `height` as the analysis variable and `sex` as the column variable.
Copied!
1%AHGtran(sashelp.class,height,sex);
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.