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)
So what's the question?
I'm not able to move ahead with these scenarios.how can this be achived with a dataset of 32 MM
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
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?
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.
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;
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.