05-08-2015 10:48 AM
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)
05-08-2015 11:02 AM
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
05-08-2015 11:59 AM
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.
05-08-2015 01:11 PM
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';
05-08-2015 03:04 PM
Can you explain your method, I can't follow it?
It doesn't appear to follow the one I suggested, for example where are the indexes calculated.
I'd also suggest trying it without the while condition until you have it working then add it in afterwards.