Quartz | Level 8

## switch

id _jan_xpn   _feb_xpn      _mar_xpn    _apr_xpn           _jan_TUNA     _feb_TUNA    _mar_TUNA     _apr_TUNA
1       600            .                .                         .                  750                      550                    .                         .
2             .           .                600                  720                575                     660                     .                        .
3              .           .                    .                 700                      .                     660                650                         .

id 1 is sweitch to TUNA
id 2 is switch  from tuna

ideally xpn will take importance over TUNA.

if the score is missing in earlier months in xpn and then score is present in later months in TUNA for that ID,it is called "New to TUNA". (ID 3)

if scores are  present in earlier months in xpn and also scores present in TUNA in later months then "switch to TUNA" (Id 1)

if scores are missing in earlier months and present in TUNA and for subsequent months the scores are present in xpn and not present in TUNA then "Switch from TUNA" (id 2)

7 REPLIES 7
Super User

## Re: switch

So what's the question?

Quartz | Level 8

## Re: switch

I'm not able to move ahead with these scenarios.how can this be achived with a dataset of 32 MM

Super User

## Re: switch

I'm going to assume your question is how to determine the direction of switch from/to Tuna.

1. Set up two arrays one for XPN and one for TUNA

2. Find the starting index of each array that is not missing - I recommend a do - while loop so you don't have to loop through the full array.

3. Compare indexes to determine direction of switch

Quartz | Level 8

## Re: switch

xpn (*) _jan_xpn _feb_xpn _mar_xpn _apr_xpn;

array tuna (*) _jan_TUNA _feb_TUNA _mar_TUNA _apr_TUNA;

well...why to find the starting index that is not missing?

Super User

## Re: switch

ID Start_XPN Start_Tuna

1 1 1

2 3 1

3 4 2

ID 2/3 are the same, switch to XPN later in the process.

ID 1 which has the same index is a different scenario that can then be coded for.

Quartz | Level 8

## Re: switch

This is not giving me the expected results:

xpn (*) _jan_xpn _feb_xpn _mar_xpn _apr_xpn;

array tuna (*) _jan_TUNA _feb_TUNA _mar_TUNA _apr_TUNA;

do i=1 to dim(xpn) while (xpn(i) ne .);

if tuna(i)=. then flag='New Account';

else  if tuna(i) > xpn(i) then flag='Switch to Tuna';

else if tuna(i) < xpn(i) then flag='Switch from  Tuna';

end;

Super User