Sample 25273: How to combine SAS generation data sets into one SAS data set
Use PROC CONTENTS to obtain the information on how many
generation data sets exist and the maximum number of generations
that can exist.
For sample data, see
Creating SAS generation data sets.
Note:
For more information on SAS generation data sets, see the SAS Language Reference: Concepts.
For the DATA= value for PROC CONTENTS and PROC APPEND, replace DSN with the name of your SAS generation data set name.
/* Use PROC CONTENTS to obtain the information on how many */
/* generations exist and the maximum number of generations */
/* that can exist. */
proc contents data=dsn out=dsncont(keep=genmax gennext) noprint;
run;
/* SET the SAS data set that is a result of PROC CONTENTS. */
/* Based on the values of GENMAX and GENNEXT, determine how */
/* many generations exist for the SAS data set and put that */
/* value into a macro variable. */
data _null_;
set dsncont;
if (gennext > genmax) then count=genmax-1;
else count=gennext-1;
call symput('count',left(put(count,8.)));
run;
/* Use macro DO loop with macro variable created in the above */
/* DATA step to determine how many times the PROC APPEND */
/* iterates to create a new SAS data set with all generations */
/* of the SAS data set. */
%macro combgens;
%do i=0 %to &count;
proc append base=newdsn data=dsn(gennum=-&i);
run;
%end;
%mend combgens;
%combgens
Use PROC CONTENTS to obtain the information on how many
generation data sets exist and the maximum number of generations that can exist.
| Type: | Sample |
| Topic: | SAS Reference ==> Procedures ==> CONTENTS Common Programming Tasks ==> Combining Data SAS Reference ==> DATA Step
|
| Date Modified: | 2009-08-12 15:58:03 |
| Date Created: | 2005-03-31 15:37:31 |
Operating System and Release Information
| SAS System | Base SAS | All | n/a | n/a |