> This is something I'll be working on in the next while with
> dental treatment data:
> I need to check on the existence of certain treatments for
> a tooth (any tooth) prior to another type of treatment. Then,
> at the end of the study period, check to see if the same tooth
> received another kind of treatment.
> All the treatments are identified and dates recorded. The two
> main groups will be the initial treatment - did they get it
> or not.
> When I put it this way it looks simple, but I don't know how
> to do it except by "brute force" - checking for the existence
> of codes one after the other (there are over a dozen initial
> codes to check for and there could be many treatment dates).
> I don't know how to write macros or scripts, and the explanations
> I've seen in the manuals and on the web make no sense to me.
> There will be potentially several treatments per patient, but
> I've already figured out how to get them into one case per
> subject using casestovars.
> Is there a macro tutorial out there somewhere?
> Many thanks!
I presume you data file has variables (columns) something
ID - unique ID for each person
DATE - date of visit
TOOTH - codes for different teeth
TX1 - indicator for treatment 1 (1=YES, 0=No)
TX2 - indicator for trematment 2 (1=YES, 0=No)
TX3 - indicator for treatment 3 (1=YES, 0=No)
If you have treatment indicators with 0/1 coding as above,
then you can use AGGREGATE (with ID and TOOTH as the break
variables) to get a SUM across all records for each person
by tooth combination. The SUM of TX1 across all rows for
Person 1, Tooth 1 tells you how many times that tooth had
treatment 1. You can reduce the sum to a binary variable
(0/1) if all you need is Yes/No.
To use AGGREGATE in the pulldown menus, I think it's
DATA/AGGREGATE when the data editor is active. The
AGGREGATE syntax (which you'll get if you click PASTE
instead of OKAY) will look something like this:
sort cases by ID TOOTH.
aggregate outfile = 'C:\temp\treatment sums.sav'
/break = ID TOOTH
/sum1 = sum(tx1)
/sum2 = sum(tx2)
/sum3 = sum(tx3).
The file 'treatment sums.sav' would have variables ID,
TOOTH, and SUM1 to SUM3. To merge it with your working data
match files file = *
/table = 'C:\temp\treatment sums.sav'
/by ID TOOTH.
Hope this helps.