Dear list,
I have the following patient data which reflect their previous (varA, varB, varC, varD, varE) and current (currentA, currentB, currentC, currentD, currentE) “drug treatment”. I will like to find out which current patients have the same regime as the previous one but they ADD ON one drug (e.g. previous: D+E, current: B+D+E; or previous: none, current: E). Also, I will like to find out the same as the above, but for a specific drug (e.g. Which patients ADD ON drug C in their current regime). I’ve transformed them into string variables since I though it will be easy to identify the previous and current patent regime, don't know if it’s necessary though. In my example there are just 5 drugs but in my date set there are more than 30. Any help will be highly appreciated it!! DATA LIST LIST / varA varB varC varD varE currentA currentB currentC currentD currentE. BEGIN DATA. 1 0 0 1 0 1 1 0 1 0 0 0 1 0 0 0 1 1 0 0 0 1 1 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 1 0 0 1 0 1 1 0 1 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 1 0 1 0 0 0 0 1 0 1 1 0 0 1 0 0 0 1 0 0 0 1 1 0 0 1 0 0 0 1 0 0 0 1 0 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 0 0 1 0 1 0 1 0 1 0 0 0 0 1 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 END DATA. exe. string drugA (a2). string drugB (a2). string drugC (a2). string drugD (a2). string drugE (a2). if (varA=1) drugA="A+". if (varB=1) drugB="B+". if (varC=1) drugC="C+". if (varD=1) drugD="D+". if (varE=1) drugE="E+". EXE. string previousregim (a10). compute previousregim=CONCAT(drugA,drugB,drugC,drugD,drugE). fre previousregim. string currentdrugA (a2). string currentdrugB (a2). string currentdrugC (a2). string currentdrugD (a2). string currentdrugE (a2). if (currentA=1) currentdrugA="A+". if (currentB=1) currentdrugB="B+". if (currentC=1) currentdrugC="C+". if (currentD=1) currentdrugD="D+". if (currentE=1) currentdrugE="E+". EXE. string currentregim (a10). compute currentregim=CONCAT(currentdrugA,currentdrugB,currentdrugC,currentdrugD,currentdrugE). fre currentregim. Let me know if you need further clarifications. Thanks. Mils
mils
|
I've used David's syntax to find out the most common combination:
http://spssx-discussion.1045642.n5.nabble.com/Most-common-combinations-of-dummy-variables-td5717128.html#a5717140 But unfortunately that won't help me to see any "add on" either. I guess I'm more interested in "sequences" but I couldn't find any previous post related to my query... Any suggestions? Thanks in advance! joan
mils
|
Administrator
|
I am truly uncertain what you wish the output to look like.
Here is a slam dunk approach to discerning differences in profile without any VECTOR/LOOP or DO REPEAT business. Any difference will appear as a 1. Any match (either 0 or 1) across corresponding elements will appear as 0. This should be sufficient info to do further processing. DATA LIST LIST / varA varB varC varD varE currentA currentB currentC currentD currentE. BEGIN DATA. 1 0 0 1 0 1 1 0 1 0 0 0 1 0 0 0 1 1 0 0 0 1 1 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 1 0 0 1 0 1 1 0 1 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 1 0 1 0 0 0 0 1 0 1 1 0 0 1 0 0 0 1 0 0 0 1 1 0 0 1 0 0 0 1 0 0 0 1 0 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 0 0 1 0 1 0 1 0 1 0 0 0 0 1 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 END DATA. exe. MATRIX. GET OLD / VAR varA TO varE/FILE */NAMES=N1. GET NEW / VAR currentA TO currentE/FILE */NAMES=N2. COMPUTE COMNames={N1,N2}. SAVE {old,new ,ABS(old-new)} / OUTFILE */ NAMES=COMNAMES . END MATRIX. FORMATS ALL (F1.0). LIST. varA varB varC varD varE currentA currentB currentC currentD currentE COL11 COL12 COL13 COL14 COL15 1 0 0 1 0 1 1 0 1 0 0 1 0 0 0 0 0 1 0 0 0 1 1 0 0 0 1 0 0 0 0 1 1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 0 1 1 0 1 0 0 0 0 1 0 0 1 0 1 1 0 1 0 1 1 0 0 0 0 0 0 1 0 1 0 1 1 1 1 0 1 0 1 0 0 0 1 0 1 0 1 0 1 0 0 1 1 1 1 0 0 1 0 1 0 1 1 0 1 0 1 0 0 0 0 1 0 0 1 0 1 1 0 1 0 0 1 0 0 0 0 0 0 1 0 1 1 0 0 1 1 1 0 1 1 0 0 0 1 0 0 0 1 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 1 1 0 0 1 0 1 0 1 0 0 1 0 1 1 0 0 0 0 1 0 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 1 1 0 1 0 1 1 0 1 0 1 0 1 0 0 0 1 1 1 0 0 1 0 1 0 1 1 1 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 Number of cases read: 18 Number of cases listed: 18
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Hi David,
Ideally, I would like a new variable/column with 1 for those add on regimes and 0 for the rest: Previous Current varaddon A+B A+B+C 1 D+E A+D+E 1 D+E D+A 0 C A 0 C 1 A+C+D A+C+D+E 1 Does that make any sense? I'm looking for does patients that add a new drug in their regime. My second question is referring to those patients that actually add a specific drug in their regime. Hope it helps. ThankS!!!!!
mils
|
Administrator
|
Get rid of ABS and swap old and new in the SAVE.
Think about what the code is doing and you will be able to figure it out. ---
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Wow...Matrix!!!
It did work, thanks David. Now, how can I do it in the same dataset? Sorry, I did try it myself by taking out 'outfile' but got error messages.
mils
|
Administrator
|
You could of course just do it in 'normal' syntax as follows:
-- DATA LIST LIST / varA varB varC varD varE currentA currentB currentC currentD currentE. BEGIN DATA. 1 0 0 1 0 1 1 0 1 0 0 0 1 0 0 0 1 1 0 0 0 1 1 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 1 0 0 1 0 1 1 0 1 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 1 0 1 0 0 0 0 1 0 1 1 0 0 1 0 0 0 1 0 0 0 1 1 0 0 1 0 0 0 1 0 0 0 1 0 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 0 0 1 0 1 0 1 0 1 0 0 0 0 1 1 0 1 0 1 0 1 0 0 0 1 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 END DATA. FORMATS ALL (F1.0). NUMERIC ChangeA ChangeB ChangeC ChangeD ChangeE (F2.0). DO REPEAT old=VarA TO VarE / new=currentA currentB currentC currentD currentE / change=ChangeA TO ChangeE. COMPUTE change=new-old. END REPEAT. LIST. OT: My brain just happened to be in MATRIX mode yesterday ;-). MATRIX: Sorely neglected gem of the old empire (powerful stuff but crippled wrt string manipulations). MACRO: Sorely neglected gem of the old empire (powerful stuff but crippled wrt number manipulations).
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me. --- "Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis." Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?" |
Free forum by Nabble | Edit this page |