Can I user Two one-dimensional arrays for comparison?

Reply
Occasional Contributor
Posts: 10

Can I user Two one-dimensional arrays for comparison?

INTENDED: Use two one dimensional arrays for comparison.

Array INNER1 to pick values from TRNS_FILLDATE_ARRAYDATA  (11/01/2012    12/16/2012    12/31/2012)

Array INNER2 to pick values from TRNSENDDATEARRAYDATA (11/16/2012    12/21/2012    01/04/2013)

When I define the second array; first array also picks up values from the second table. Can I successfully define Array 1 from Table 1 and Array 2 from Table 2 to do the compare

Much thanks for kind help

Following is my code:

Data _null_;

*FIRST ARRAY;

set WORK.TRNS_FILLDATE_ARRAYDATA (DROP= Source);

array inner1{*} _numeric_;

*SECOND ARRAY;

set WORK.TRNSENDDATEARRAYDATA(DROP= Source);

array inner2{*} _numeric_;

counter = 0;

i=1;

j = DIM(INNER2)-1;

k=2;

l=DIM(INNER1);

do x= i to j;

     do y= k to l;

          ENDDATE = inner2(x);

          SRVDATE = inner1(y);

          Counter + (inner2(x) > inner1(y));

          Put x inner2(x)  y inner1(y) counter;

     end;

k=k+1;

end;

run;

RESULTS OF PUT STATEMENT FROM THE LOG

1   11/16/2012    2    12/21/2012    0

1   11/16/2012    3    01/04/2013    0

2   12/21/2012   3     01/04/2013    0

Super Contributor
Posts: 644

Re: Can I user Two one-dimensional arrays for comparison?

Posted in reply to Apprentice

The problem with your code is that the second array statement defined over _numeric_ will pick up all numeric variables, including those already assigned to the first array.

Assuming your first data set contains variables first1 and last1, and the second first2 and last2, you can populate the arrays correctly as follows:

     array inner1{*} first1 -- last1 ;

     ...

     array inner2{*} first2 -- last2 ;

i do not have enough information on the structure of the input tables and the result you require to tell whether the rest of the code will achieve the output you require.

Ricahrd

Ask a Question
Discussion stats
  • 1 reply
  • 143 views
  • 0 likes
  • 2 in conversation