Programming challenge...

Programming challenge...

Post by Philip Feel » Sat, 19 Jul 2003 08:32:38



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!

Phil

 
 
 

Programming challenge...

Post by Bruce Weave » Sat, 19 Jul 2003 22:04:27



> 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!

> Phil

I presume you data file has variables (columns) something
like this:

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)
etc

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'
  /presorted
  /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
file:

match files file = *
  /table =  'C:\temp\treatment sums.sav'
  /by ID TOOTH.
exe.

Hope this helps.
Cheers,
Bruce
--
Bruce Weaver

www.angelfire.com/wv/bwhomedir/

 
 
 

1. Excel programming challenge

Excel Experts:

I am a journalist who is learning to use Excel. I've never posted here
before, but I am hoping someone in this group can point me in the right
direction.

I've got an interesting problem with a large Excel workbook, and it
looks like the kind of thing that could only be solved with some
scripting or programming in Excel, which is not my strong suit. I'm
willing to dive into the manuals and figure out a solution, but I wanted
to post the problem here first to see if anyone out there has already
solved this one.

I have two workbooks each containing 99 worksheets, one for each of
Minnesota's 87 counties, plus a state aggregate and some regional
aggregates. There is a workbook for 1990 data and one for 1995 data. The
sheets are laid out almost identically within each workbook, with about
70 rows of data per sheet.

But, and herein lies the problem, there are differences between the two
workbooks: Some rows displayed in 1995 are collapsed into other rows in
1990. Rows with no data are filled in with NA in each cell in 1995, but
simply omitted in 1990. The inconsistencies vary from sheet to sheet --
some contain rows found in the 1995 book, some don't -- which suggests
to me an "If, then" routine rather than a simple Consolidate.

What I want to do is automate the process of reconciling the two
workbooks. When I'm done I want the 1995 sheets to conform to the 1990
layouts, so I can easily run 1990-1995 comparisons.

Soooooo ... if you've developed a solution like this, I'd love to see
it. Or if you can give me a nudge on where to find the solution in Help
or the manual, I'd appreciate that, too. Thanks!

-------------------------------------------
Bill Loving, Computer-Assisted Reporting Editor
Minneapolis Star Tribune
425 Portland Ave, Minneapolis MN 55488
voice: 612-673-4493 fax: 612-673-4359

2. Form action-question

3. Help! Macintosh Excel 5/VBA programming challenge

4. FS Unique MIDI keyboard that wraps around a pole

5. weird sort problem | programming challenge

6. Virtual Memory/Memory Protection Proposal (Big, Technical)

7. MasPar Data-Parallel Programming Challenge

8. Sun GDM-1962B Monitor, Possible FAQ

9. CFP: GRID WARS CHALLENGE - The Battle For Processors - Parallel Programming Championship

10. 16 bit challenge - we HAVE a winner!

11. 16 bit challenge vote

12. 16 bit challenge - you may change your vote if you'd like