Online File

How to use this page


Rick Aster: Professional SAS Programming Shortcuts: Contents

Chapter 55
Program
Calendar pseudo-array lookup


DATA HISTORY.TRANS;
   * Load calendar data from calendar dataset. ;
   LENGTH OPENSTR $ 370;
   RETAIN CAL_BASE OPENSTR;
   IF _N_ = 1 THEN DO;
      CAL_BASE = MDY(1, 1, YEAR) - 1;
      DO DATE = MDY(1, 1, YEAR) TO MDY(12, 31, YEAR);
         SET CORP.CALENDAR KEY=DATE/UNIQUE;
         SUBSTR(OPENSTR, DATE - CAL_BASE, 1) = OPENDAY;
         END;
      END;
   * Check transaction dates. ;
   MODIFY HISTORY.TRANS;
   IF CAL_BASE < DATE < CAL_BASE + 370;
   * Find a transaction recorded on a closed day. ;
   IF SUBSTR(OPENSTR, DATE - CAL_BASE, 1) = '0';
   * Change date to next open day. ;
   DO UNTIL (SUBSTR(OPENSTR, DATE - CAL_BASE, 1) = '1');
      DATE + 1;
      IF DATE >= CAL_BASE + 370 THEN LEAVE;
      END;
    REPLACE;
RUN;

 O /\

Global
Statements

RICK ASTER

SAS

BOOKS

Tech | Dictionary

Download | Rastinate

Rick Aster

Professional SAS Programming Shortcuts

Contents/Online Files

Corrections

Catalog Page