Computing new variable-challenging issue

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Computing new variable-challenging issue

Warda
Hi guys, I need guidance please
I am working on a dataset that has patients and medications. The file is in
long format. Each patient has multiple rows of medications some of which are
repeated. I used the following syntax to create new variables specifiying
categories of medication.

COMPUTE STEROID=0.
DO IF CHAR.INDEX(UPCASE(MEDICINE), 'BECLOMETHASONE') GT 0.
COMPUTE STEROID=1.
ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'DEXAMETHASONE') GT 0.
  COMPUTE STEROID=1.
ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'FLUTIC') GT 0.
  COMPUTE STEROID=1.
ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'HYDROCORTIS') GT 0.
  COMPUTE STEROID=1.
ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'IPRATROP') GT 0.
  COMPUTE STEROID=1.
ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'PREDNIS') GT 0.
  COMPUTE STEROID=1.
ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'ECLOMETHASONE') GT 0.
  COMPUTE STEROID=1.
END IF.
EXECUTE.

COMPUTE SAB2RA=0.
DO IF CHAR.INDEX(UPCASE(MEDICINE), 'SALBUTAMOL') GT 0.
COMPUTE SAB2RA =1.
END IF.
EXECUTE.

COMPUTE LAB2RA=0.
DO IF CHAR.INDEX(UPCASE(MEDICINE), 'SALMETEROL') GT 0.
COMPUTE LAB2RA =1.
END IF.
EXECUTE.

COMPUTE ANTIBIOTICS=0.
DO IF CHAR.INDEX(UPCASE(MEDICINE), 'AMOX') GT 0.
COMPUTE ANTIBIOTICS=1.
ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'AZITHROMYCIN') GT 0.
  COMPUTE ANTIBIOTICS=1.
ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'CEFUROXIME') GT 0.
  COMPUTE ANTIBIOTICS=1.
ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'CEPHALEXIN') GT 0.
  COMPUTE ANTIBIOTICS=1.
ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'PHENOXYMETH') GT 0.
  COMPUTE ANTIBIOTICS=1.
END IF.
EXECUTE.


My issue now is the repetition of medication for each patient. Some patients
have 240 entries and if repetitions are deleted what remains is only 5. I
wanted to know how can I write a syntax for choosing one observation only
per patient to overcome the repetition issue. For example, code 1 for
corticosteroids  once only for each patient if found (despite using
different possible options).
I don't know even if this is possible.
Can someone help?

Thank you



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Computing new variable-challenging issue

David Marso
Administrator
This is unnecessarily long winded and inefficient (EXECUTE statements are NOT
necessary).
Consider the following
STRING medtmp (A100).
COMPUTE medtmp =MEDICINE.
COMPUTE steroid=
  SUM(CHAR.INDEX(medtmp , 'BECLOMETHASONE') ,
         CHAR.INDEX(medtmp , 'DEXAMETHASONE') ,
         CHAR.INDEX(medtmp , 'FLUTIC') ,
         CHAR.INDEX(medtmp , 'HYDROCORTIS') ,
         CHAR.INDEX(medtmp , 'IPRATROP') ,
         CHAR.INDEX(medtmp , 'PREDNIS') ,
         CHAR.INDEX(medtmp , 'ECLOMETHASONE') ) GT 0.

OR if the full medicine values are the target you can use.
 
STRING medtmp (A100).
COMPUTE steroid=ANY(medtmp ,'BECLOMETHASONE','DEXAMETHASONE','FLUTIC',...
etc).

Similar logic applies to the remainder.  
Please delete those EXECUTE commands, they are an abomination.

"Some patients
have 240 entries and if repetitions are deleted what remains is only 5. I
wanted to know how can I write a syntax for choosing one observation only
per patient to overcome the repetition issue."

Please study the AGGREGATE command.

AGGREGATE OUTFILE * / BREAK patientID medicine / N=N.




Warda wrote

> Hi guys, I need guidance please
> I am working on a dataset that has patients and medications. The file is
> in
> long format. Each patient has multiple rows of medications some of which
> are
> repeated. I used the following syntax to create new variables specifiying
> categories of medication.
>
> COMPUTE STEROID=0.
> DO IF CHAR.INDEX(UPCASE(MEDICINE), 'BECLOMETHASONE') GT 0.
> COMPUTE STEROID=1.
> ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'DEXAMETHASONE') GT 0.
>   COMPUTE STEROID=1.
> ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'FLUTIC') GT 0.
>   COMPUTE STEROID=1.
> ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'HYDROCORTIS') GT 0.
>   COMPUTE STEROID=1.
> ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'IPRATROP') GT 0.
>   COMPUTE STEROID=1.
> ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'PREDNIS') GT 0.
>   COMPUTE STEROID=1.
> ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'ECLOMETHASONE') GT 0.
>   COMPUTE STEROID=1.
> END IF.
> EXECUTE.
>
> COMPUTE SAB2RA=0.
> DO IF CHAR.INDEX(UPCASE(MEDICINE), 'SALBUTAMOL') GT 0.
> COMPUTE SAB2RA =1.
> END IF.
> EXECUTE.
>
> COMPUTE LAB2RA=0.
> DO IF CHAR.INDEX(UPCASE(MEDICINE), 'SALMETEROL') GT 0.
> COMPUTE LAB2RA =1.
> END IF.
> EXECUTE.
>
> COMPUTE ANTIBIOTICS=0.
> DO IF CHAR.INDEX(UPCASE(MEDICINE), 'AMOX') GT 0.
> COMPUTE ANTIBIOTICS=1.
> ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'AZITHROMYCIN') GT 0.
>   COMPUTE ANTIBIOTICS=1.
> ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'CEFUROXIME') GT 0.
>   COMPUTE ANTIBIOTICS=1.
> ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'CEPHALEXIN') GT 0.
>   COMPUTE ANTIBIOTICS=1.
> ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'PHENOXYMETH') GT 0.
>   COMPUTE ANTIBIOTICS=1.
> END IF.
> EXECUTE.
>
>
> My issue now is the repetition of medication for each patient. Some
> patients
> have 240 entries and if repetitions are deleted what remains is only 5. I
> wanted to know how can I write a syntax for choosing one observation only
> per patient to overcome the repetition issue. For example, code 1 for
> corticosteroids  once only for each patient if found (despite using
> different possible options).
> I don't know even if this is possible.
> Can someone help?
>
> Thank you
>
>
>
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD





-----
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?"
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
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?"
Reply | Threaded
Open this post in threaded view
|

Re: Computing new variable-challenging issue

Bruce Weaver
Administrator
I was about to post code similar to David's below.  On the line that computes
new variable medtmp, I would include the UPCASE function, like this:

COMPUTE medtmp = UPCASE(MEDICINE).

HTH.


David Marso wrote

> This is unnecessarily long winded and inefficient (EXECUTE statements are
> NOT
> necessary).
> Consider the following
> STRING medtmp (A100).
> COMPUTE medtmp =MEDICINE.
> COMPUTE steroid=
>   SUM(CHAR.INDEX(medtmp , 'BECLOMETHASONE') ,
>          CHAR.INDEX(medtmp , 'DEXAMETHASONE') ,
>          CHAR.INDEX(medtmp , 'FLUTIC') ,
>          CHAR.INDEX(medtmp , 'HYDROCORTIS') ,
>          CHAR.INDEX(medtmp , 'IPRATROP') ,
>          CHAR.INDEX(medtmp , 'PREDNIS') ,
>          CHAR.INDEX(medtmp , 'ECLOMETHASONE') ) GT 0.
>
> OR if the full medicine values are the target you can use.
>  
> STRING medtmp (A100).
> COMPUTE steroid=ANY(medtmp ,'BECLOMETHASONE','DEXAMETHASONE','FLUTIC',...
> etc).
>
> Similar logic applies to the remainder.  
> Please delete those EXECUTE commands, they are an abomination.
>
> "Some patients
> have 240 entries and if repetitions are deleted what remains is only 5. I
> wanted to know how can I write a syntax for choosing one observation only
> per patient to overcome the repetition issue."
>
> Please study the AGGREGATE command.
>
> AGGREGATE OUTFILE * / BREAK patientID medicine / N=N.
>
>
>
>
> Warda wrote
>> Hi guys, I need guidance please
>> I am working on a dataset that has patients and medications. The file is
>> in
>> long format. Each patient has multiple rows of medications some of which
>> are
>> repeated. I used the following syntax to create new variables specifiying
>> categories of medication.
>>
>> COMPUTE STEROID=0.
>> DO IF CHAR.INDEX(UPCASE(MEDICINE), 'BECLOMETHASONE') GT 0.
>> COMPUTE STEROID=1.
>> ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'DEXAMETHASONE') GT 0.
>>   COMPUTE STEROID=1.
>> ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'FLUTIC') GT 0.
>>   COMPUTE STEROID=1.
>> ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'HYDROCORTIS') GT 0.
>>   COMPUTE STEROID=1.
>> ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'IPRATROP') GT 0.
>>   COMPUTE STEROID=1.
>> ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'PREDNIS') GT 0.
>>   COMPUTE STEROID=1.
>> ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'ECLOMETHASONE') GT 0.
>>   COMPUTE STEROID=1.
>> END IF.
>> EXECUTE.
>>
>> COMPUTE SAB2RA=0.
>> DO IF CHAR.INDEX(UPCASE(MEDICINE), 'SALBUTAMOL') GT 0.
>> COMPUTE SAB2RA =1.
>> END IF.
>> EXECUTE.
>>
>> COMPUTE LAB2RA=0.
>> DO IF CHAR.INDEX(UPCASE(MEDICINE), 'SALMETEROL') GT 0.
>> COMPUTE LAB2RA =1.
>> END IF.
>> EXECUTE.
>>
>> COMPUTE ANTIBIOTICS=0.
>> DO IF CHAR.INDEX(UPCASE(MEDICINE), 'AMOX') GT 0.
>> COMPUTE ANTIBIOTICS=1.
>> ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'AZITHROMYCIN') GT 0.
>>   COMPUTE ANTIBIOTICS=1.
>> ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'CEFUROXIME') GT 0.
>>   COMPUTE ANTIBIOTICS=1.
>> ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'CEPHALEXIN') GT 0.
>>   COMPUTE ANTIBIOTICS=1.
>> ELSE IF CHAR.INDEX (UPCASE(MEDICINE), 'PHENOXYMETH') GT 0.
>>   COMPUTE ANTIBIOTICS=1.
>> END IF.
>> EXECUTE.
>>
>>
>> My issue now is the repetition of medication for each patient. Some
>> patients
>> have 240 entries and if repetitions are deleted what remains is only 5. I
>> wanted to know how can I write a syntax for choosing one observation only
>> per patient to overcome the repetition issue. For example, code 1 for
>> corticosteroids  once only for each patient if found (despite using
>> different possible options).
>> I don't know even if this is possible.
>> Can someone help?
>>
>> Thank you
>>
>>
>>
>> --
>> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>
>> LISTSERV@.UGA
>
>>  (not to SPSSX-L), with no body text except the
>> command. To leave the list, send the command
>> SIGNOFF SPSSX-L
>> For a list of commands to manage subscriptions, send the command
>> INFO REFCARD
>
>
>
>
>
> -----
> 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?"
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

>  (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD





-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
Reply | Threaded
Open this post in threaded view
|

Re: Computing new variable-challenging issue

Warda
In reply to this post by David Marso
Thank you David, will try to study Aggregation and I hope you don't mind if I
email you for consultation.

Warda



--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD