DATA Step, Macro, Functions and more

All variables is defined as NUM 8, please help

Reply
Occasional Contributor
Posts: 15

All variables is defined as NUM 8, please help

Hi,

 

I am submitting the below code, all the array variables plus the three keys i.e. PARTY_ID, SORT_CODE and ACCOUNT_NUMBER - all variables are assigned NUM 8 data type. Please can you advise how to fix it.

%LET MAXOCC = 12;

DATA DATA1(COMPRESS=YES);
  INFILE INFLAT MISSOVER OBS=MAX;
  INPUT @1 RECTYPE £2. @;
  IF RECTYPE = '20';
  INPUT
@22   MONTHNO 3.
@49   SORT_CODE 6.
@55   ACCOUNT_NUMBER 8.
@69   PARTY_ID 10.
@857  I_DETS_CURR_NO_ARRS_DISP_AJ  1.
@449  I_DETS_WST_ARS_L6M_DISP_AJ_TM    1.
@712  I_ACTUAL_NEXT_DUE_DAY    ZD8.;

IF MONTHNO > 0 AND MONTHNO <= &MAXOCC ;
RUN;

PROC SORT DATA=DATA1; BY PARTY_ID SORT_CODE ACCOUNT_NUMBER MONTHNO;

DATA OUTFLAT.OUTDATA (KEEP = PARTY_ID SORT_CODE ACCOUNT_NUMBER
DETS_CURR_NO_ARRS_DISP_AJ1-DETS_CURR_NO_ARRS_DISP_AJ&MAXOCC
DETS_WST_ARS_L6M_DISP_AJ_TM1-DETS_WST_ARS_L6M_DISP_AJ_TM&MAXOCC
ACTUAL_NEXT_DUE_DAY1-ACTUAL_NEXT_DUE_DAY&MAXOCC);

ARRAY DETS_CURR_NO_ARRS_DISP_AJ(&MAXOCC)
DETS_CURR_NO_ARRS_DISP_AJ1-DETS_CURR_NO_ARRS_DISP_AJ&MAXOCC;
RETAIN DETS_CURR_NO_ARRS_DISP_AJ1-DETS_CURR_NO_ARRS_DISP_AJ&MAXOCC;

ARRAY DETS_WST_ARS_L6M_DISP_AJ_TM(&MAXOCC)
DETS_WST_ARS_L6M_DISP_AJ_TM1-DETS_WST_ARS_L6M_DISP_AJ_TM&MAXOCC;
RETAIN DETS_WST_ARS_L6M_DISP_AJ_TM1-DETS_WST_ARS_L6M_DISP_AJ_TM&MAXOCC;

ARRAY ACTUAL_NEXT_DUE_DAY(&MAXOCC)
ACTUAL_NEXT_DUE_DAY1-ACTUAL_NEXT_DUE_DAY&MAXOCC;
RETAIN ACTUAL_NEXT_DUE_DAY1-ACTUAL_NEXT_DUE_DAY&MAXOCC;

SET DATA1; BY PARTY_ID SORT_CODE ACCOUNT_NUMBER;

IF FIRST.PARTY_ID OR
FIRST.SORT_CODE OR
FIRST.ACCOUNT_NUMBER
THEN DO;
       DO I = 1 TO &MAXOCC ;
          DETS_CURR_NO_ARRS_DISP_AJ(I) = .;
          DETS_WST_ARS_L6M_DISP_AJ_TM(I) = .;
          ACTUAL_NEXT_DUE_DAY(I) = .;
       END;
     END;
DETS_CURR_NO_ARRS_DISP_AJ(MONTHNO) = I_DETS_CURR_NO_ARRS_DISP_AJ;
DETS_WST_ARS_L6M_DISP_AJ_TM(MONTHNO) = I_DETS_WST_ARS_L6M_DISP_AJ_TM;
ACTUAL_NEXT_DUE_DAY(MONTHNO) = I_ACTUAL_NEXT_DUE_DAY;

IF LAST.PARTY_ID OR
LAST.SORT_CODE OR
LAST.ACCOUNT_NUMBER
THEN DO;
       FILE OUTFLAT;
       PUT @1  PARTY_ID       10.
           @12 SORT_CODE  6.
           @19 ACCOUNT_NUMBER 8. @;

       DO I = 1 TO &MAXOCC;
          POS = 28 + I;
          PUT @POS DETS_CURR_NO_ARRS_DISP_AJ(I) 1.
          PUT @POS DETS_WST_ARS_L6M_DISP_AJ_TM(I) 1.
          PUT @POS ACTUAL_NEXT_DUE_DAY(I) ZD8. @;
       END;

       PUT;
       OUTPUT;
     END;

PROC PRINT DATA=OUTFLAT.OUTDATA (OBS=100);
TITLE3='FISRT 100 OBS IN OUTDATA';
VAR PARTY_ID SORT_CODE ACCOUNT_NUMBER
DETS_CURR_NO_ARRS_DISP_AJ1-DETS_CURR_NO_ARRS_DISP_AJ&MAXOCC
DETS_WST_ARS_L6M_DISP_AJ_TM1-DETS_WST_ARS_L6M_DISP_AJ_TM&MAXOCC
ACTUAL_NEXT_DUE_DAY1-ACTUAL_NEXT_DUE_DAY&MAXOCC;
RUN;

RUN;
Trusted Advisor
Posts: 1,849

Re: All variables is defined as NUM 8, please help

Posted in reply to tapas_16880

It is impossible to fix your code without having you input - at list a test example - and without the log of your run.

 

Trying to run your code as is I got:

1) informat  £2. is unknown. Did you mean informat $2.  ?

2) no logical assign for filename INFLAT

 

Without input I can't help you more.

Super User
Posts: 6,939

Re: All variables is defined as NUM 8, please help

Posted in reply to tapas_16880

In general, the dollar sign indicates character variables.  That applies to both the INPUT and the PUT statements.  So if PARTY_ID is supposed to be a character variable, part of the INPUT statement would be:

 

@69 PARTY_ID $10.

 

And part of the PUT statement would be:

 

@1 PARTY_ID $10.

 

This could conceivably apply to your ARRAY statements as well.  If any of the arrays refer to character variables, you would need to insert instructions within the ARRAY statement.  For example:

 

ARRAY DETS_CURR_NO_ARRS_DISP_AJ(&MAXOCC) $ 1
DETS_CURR_NO_ARRS_DISP_AJ1-DETS_CURR_NO_ARRS_DISP_AJ&MAXOCC;

 

You know (and we don't) which variables are supposed to be character.  So tend to that much first, and see if any issues remain.

Super User
Posts: 24,028

Re: All variables is defined as NUM 8, please help

Posted in reply to tapas_16880

@tapas_16880 fix it to what? You don't actually say...

 

 

When you specify values in the INPUT statement it is assumed as an INFORMAT not the type. If you want the types declared, i.e. length and type then you need to do it manually before your INPUT statement. A Length statement is a good method.

 

length accountNumber $8 sort_code $6 party_ID $6.; *for character;

length i_dets_curr_no_arrs_disp_aj 8. ;

You should also note the the length for numeric variables it the number of bytes it can store, not that 8 means it will have 8 digits. 

Ask a Question
Discussion stats
  • 3 replies
  • 118 views
  • 2 likes
  • 4 in conversation