SAS Tutorial: Coding PUTs Without Coding PUTs

LISTING 4: The HDRIN SAS Macro Source Code

001 %GLOBAL HDRIN_N ;
002 %GLOBAL HLEN;
003 %MACRO HDRIN(HDRMBR,WRK_OUT,VLEN);
004 %*********************************************************************;
005 %** MACRO:....: HDRIN                                              ***;
006 %** FILE......: AAAA.PLAXCO.SASMACS(HDRIN)                         ***;
007 %** AUTHOR....: JIM PLAXCO                                         ***;
008 %** PURPOSE...: SAS MACRO TO READ IN A HEADER FILE                 ***;
009 %** PARAMETERS: HDRMBR.. DATASET CONTAINING HEADER DATA            ***;
010 %**             WRK_OUT. WORK.DATASET TO HOLD THE HEADER DATA      ***;
011 %**             VLEN.... MAXIMUM NUMBER OF COLUMNS TO READ IN      ***;
012 %**                                                                ***;
013 %** OUTPUT....: HDRIN_N= MACRO VARIABLE WITH THE NUMBER OF LINES   ***;
014 %**                      IN THE COLUMN HEADING FILE                ***;
015 %**             HLEN   = NUMBER OF BYTES IN EACH COLUMN LINE       ***;
016 %**                                                                ***;
017 %*********************************************************************;
018 DATA &WRK_OUT. (DROP=LINES);
019    INFILE "&HDRMBR" LENGTH=RECLEN MISSOVER END=EOFFLAG;
020    RETAIN LINES 0;
021    INPUT @1 HDRDATA $VARYING&VLEN.. RECLEN;
022    LINES+1;
023    IF EOFFLAG THEN CALL SYMPUT('HDRIN_N',LINES);
024    %LET HLEN = %EVAL(&VLEN);
025 %MEND HDRIN;

Return to the SAS Tutorial: Coding PUTs Without Coding PUTs tutorial.