The macro iterates over a list of datasets provided as a parameter. For each dataset, it creates a temporary copy, optionally adds identification columns (order, source name), and converts all data to character type via calls to other utility macros (AHGalltocharnew, AHGmergeprint). The processed datasets are then concatenated into a single table, cleaned, and optionally printed.
Data Analysis
Type : EXTERNE
Source data is defined by the &dsns macro parameter, which expects a list of existing table names.
1 Code Block
DATA STEP Data
Explanation : Processing loop: for each input table, creation of a temporary table, addition of metadata variables (order, origin), and conversion of content to character format via external macros.
Copied!
%do i=1 %to &dsnN;
%let item=%scan(&dsns,&i,%str( ));
%AHGgettempname(onedsn);
%let alldsn=&alldsn &onedsn;
data &onedsn;
%if %AHGnonblank(&ord) %then &ord=&i;;
%if %AHGnonblank(&by) %then %do;
format &by $40.; &by="&item";
%end;
set &item;
run;
%AHGalltocharnew(&onedsn,out=&onedsn);
/* ... collecte des variables et appel AHGmergeprint ... */
%end;
1
%DO i=1 %to &dsnN;
2
%let item=%scan(&dsns,&i,%str( ));
3
%AHGgettempname(onedsn);
4
%let alldsn=&alldsn &onedsn;
5
DATA &onedsn;
6
%IF %AHGnonblank(&ord) %THEN &ord=&i;;
7
%IF %AHGnonblank(&BY) %THEN %DO;
8
FORMAT &BY $40.; &BY="&item";
9
%END;
10
SET &item;
11
RUN;
12
%AHGalltocharnew(&onedsn,out=&onedsn);
13
/* ... collecte des variables et appel AHGmergeprint ... */
14
%END;
2 Code Block
DATA STEP Data
Explanation : Final concatenation step: grouping all prepared temporary tables into a single output table.
Copied!
data &out;
set &alldsn;
run;
1
DATA &out;
2
SET &alldsn;
3
RUN;
3 Code Block
MACRO CALL
Explanation : Post-processing: selection of variables to keep, cleaning of character strings (trim), and optional display of the result.
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.
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. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.