0

Sample data:

PatID Strata1 Strata2 Allocated TG      
    1       1       1           T1
    2       1       2           T2
    3       2       3           T1
    4       1       3            .
    5       2       2            .
    6       1       3            .
    7       1       3            .
    8       2       4            .

I have patients with one of 2 strats (conditions).

I will have to calculate the Allocated TG based on strats as well as Allocated TG for all the previous patients.In the above example, Allocated TG is present for 3 patients for example.

For the 4th patient,the allocated TG will be calculated like this,

What is the value for Strata1.

  1. If 1,count of how many previous patients are assigned to Allocated TG T1 when 1 count of how many previous patients are assigned to Allocated TG T2 when 1

  2. If 2,count of how many previous patients are assigned to Allocated TG T1 when 1 count of how many previous patients are assigned to Allocated TG T2 when 1

Similarly, for the Strata2.The count of all the previous patients Allocated TG based on each strata.

After all that, i will get some value for each.Based on the output value, with which strata the allocation number is less, that TG(T1/T2) will be allocated.

After this, it has to calculate for PatID5.Again which has to calculate for the previous 4 patients.

JDB
  • 25,172
  • 5
  • 72
  • 123
  • 2
    Welcome to SO. You should provide some more details on what calculations you want to do. I'm guessing you want to do something to the n'th observation based on the (n-1)th observation, but you need to give more information. – Hong Ooi Jul 10 '13 at 12:30
  • 1
    If you could provide a small example of what you want to achieve (like 6 lines of data and what you expect as result), that would help a lot. But most likely, you should just look into the retain statement. – mvherweg Jul 10 '13 at 12:37
  • Hi Both, I have updated or improved my question.Please have a look now. :) – user2568403 Jul 10 '13 at 13:04
  • I edited your question to make it clearer, but I think you still need to provide a bit more clear information. Can you post a dataset with calculated TG2s for the remaining 5 rows - what ought they be? Also, this sounds like it could be ordered - ie, it's important that patient 4 be calculated before patient 5, is that true? Finally, you need to show us what you've tried already; this is not a 'do your work for you' site, but help on specific issues. What are you stumbling on? – Joe Jul 10 '13 at 13:46
  • Hi Joe, I have not yet calculated. I am also in the coding stage still. Yes, It will be calculated patient ID wise In ascending order only. Since I am not aware much of macros, I am still reading the books/going through different sites to finding out the way/logic to implement this  – user2568403 Jul 10 '13 at 13:57
  • And , Thank you for editing the question in readable way Joe. :) – user2568403 Jul 10 '13 at 13:59
  • 2
    If you're unable to manually work this out for the above example, you're not going to be able to get any help here. I suggest you spend time working out how to do this and then edit your question to reflect what issues you may be having. – Joe Jul 10 '13 at 14:13
  • What is "Allocated TG"? Please don't use domain-specific language - it just makes things harder to understand. Your bullet points 1. and 2. under "What is the value for Strata1" say *exactly* the same thing (other than "If 1" and "If 2"). Was that intentional? – JDB Jul 10 '13 at 20:34

1 Answers1

0

Programmers prefer a batch mode kind of approach instead of doing it line by line for faster performance. You can use firstobs and obs in loops. For batchmode, use obs- firstobs as 1000 or some number, for line by line use obs=firstobs+1

Kuber
  • 1,023
  • 12
  • 21