BookmarkSubscribeRSS Feed
tapas_16880
Calcite | Level 5

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;
3 REPLIES 3
Shmuel
Garnet | Level 18

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.

Astounding
PROC Star

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.

Reeza
Super User

@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. 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 730 views
  • 2 likes
  • 4 in conversation