Hi,
I think having not programmed anything new lately has really deteriorated my skills.
I have a really long program. I want to create a secondary QA dataset which captures all the table names, observations numbers, variable numbers as the program is running. This way in each step, I can compare observation numbers to ensure that they all match. This needs to be automated which is why I am asking for help here.
How do I do this in a macro? I know how to set up macro variables to do this (see below). However, I cannot figure out how to do it in a dataset.
%MACRO OBSNVARS(DS);
%GLOBAL DSET NVARS NOBS;
%LET DSET=&DS;
/* OPEN DATA SET PASSED AS THE MACRO PARAMETER */
%LET DSID = %SYSFUNC(OPEN(&DSET)); /*1 IF DATASET EXISTS; 0 IF DATASET DOES NOT EXIST*/
/* IF THE DATA SET EXISTS, GET THE NUMBER OF OBSERVATIONS */
/* AND VARIABLES AND THEN CLOSE THE DATA SET */
%IF &DSID %THEN
%DO;
%LET NOBS =%SYSFUNC(ATTRN(&DSID,NOBS));
%LET NVARS=%SYSFUNC(ATTRN(&DSID,NVARS));
%LET RC = %SYSFUNC(CLOSE(&DSID));
%END;
/* OTHERWISE, WRITE A MESSAGE THAT THE DATA SET COULD NOT BE OPENED */
%ELSE %PUT OPEN FOR DATA SET &DSET FAILED - %SYSFUNC(SYSMSG());
%MEND OBSNVARS;
... View more