Crosstab only allows me to do 3 columns, can't do more than that. Perhaps I'm not writing the query correctly.
Based on the data you provided, a crosstab would have produced whatever columns you wanted to show (e.g. AccessIDCode, PatientLinkCode. SurgeonID, FacilityLocation, etc) plus a further eleven columns for CCPXCODE, so sounds like you are not writing it correctly (or have filtered to one row for testing) - suggest you post the SQL you tried to use. However if you want two columns for each CCPXCODE, one with a binary value and one with a date then you will need two crosstabs which you then combine in a third query.
The statistician that we are working with will not do any modification of the data that is provided (researcher integrity)
Sounds like an excuse to me - if you added another CCPXCODE then they will need to completely rewrite their analysis - but then, someone else is paying the bill for the extra work (sorry, just me being cynical, everyone tries to make their job easier). After all, you will be exporting the same number of rows as you have at the moment, with (based on the current data), 22 columns related to CCPXCODE, but only 2 populated per row
ONLY the data that we provide
Precisely - they would not be changing it, all you are doing is moving a date to a different column based on the CCPXCODE and adding another column which is effectively saying 'there is a date in the next column'.
Also, there may be some codes that we want to remove before we analyze it.
easily done with a filter
Based on the data provided, this code should give you the 'procedure date' crosstab - I've used your names so you should be able to just copy and paste, save as QCB1
Code:
TRANSFORM First(YAGCombinedBackup.ProcedureDate) AS FirstOfProcedureDate
SELECT YAGCombinedBackup.AccessIDCode, YAGCombinedBackup.PatientLinkCode, YAGCombinedBackup.ICD9XCODE1, YAGCombinedBackup.ICD9XCODE2, YAGCombinedBackup.ICD9XCODE3, YAGCombinedBackup.DateOfFirstYAG, YAGCombinedBackup.SurgeonID
FROM YAGCombinedBackup
GROUP BY YAGCombinedBackup.AccessIDCode, YAGCombinedBackup.PatientLinkCode, YAGCombinedBackup.ICD9XCODE1, YAGCombinedBackup.ICD9XCODE2, YAGCombinedBackup.ICD9XCODE3, YAGCombinedBackup.DateOfFirstYAG, YAGCombinedBackup.SurgeonID
PIVOT YAGCombinedBackup.CCPXCODE
This gives you the 'binary' crosstab - save as QCB2
Code:
TRANSFORM First(Abs([ProcedureDate]=[ProcedureDate])) AS Expr1
SELECT YAGCombinedBackup.AccessIDCode
FROM YAGCombinedBackup
GROUP BY YAGCombinedBackup.AccessIDCode
PIVOT YAGCombinedBackup.CCPXCODE
And this combines them - you'll need to add all the relevant CCPXCODE codes, I've just done two
Code:
SELECT QCB1.AccessIDCode, QCB1.PatientLinkCode, QCB1.ICD9XCODE1, QCB1.ICD9XCODE2, QCB1.ICD9XCODE3, QCB1.DateOfFirstYAG, QCB1.SurgeonID, QCB1.[28.4 A], QCB2..[28.4 A], QCB1.[28.74B], QCB2.[28.74B]
FROM QCB1 INNER JOIN QCB2 ON QCB1.AccessIDCode = QCB2.AccessIDCode;