IF THEN

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

IF THEN

Lacay, Phebe
Hi all,

It's me again.

 

I am trying to do a recode.  I am not sure if I should be doing a DO
IF??

Any suggestions?

 

(all are string)

If CNTY=missing or '999' and STATE= '99' then CNTY='00'

If CNTY=missing or '999' and STATE='34' then CNTY='88

If CNTY=missing or '999' and STATE~='34' then CNTY='99'

                                   

Thanks,

Phebe

 

 

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

'replace' does not work on new text

Zdaniuk, Bozena-2
Hello, I am using spss 15 and I just ran into this problem:

When I copy and paste some text within a syntax file and then want to use the find-and-replace function, it does not recognize (find) the newly copied text. I need to save and re-open, sometimes more than once, the syntax file for the find-and-replace function to recognize the new text. Is this a bug? Is there a patch for it?
Thanks, everyone.
Bozena

Bozena Zdaniuk, Ph.D.
University of Pittsburgh
UCSUR, 6th Fl.
121 University Place
Pittsburgh, PA 15260
Ph.: 412-624-5736
Fax: 412-624-4810
Email: [hidden email]

=====================
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: 'replace' does not work on new text

John M. Trent
I did this yesterday and had no problem...not sure whats up with your situation...

John Mark

John Mark Trent, PhD
Educational Psychologist
Family Therapist

Change occurs only as we begin thinking about and working on the self ---
rather than staying focused on and reactive to the other
http://relationalgrace.blogspot.com/



________________________________

From: SPSSX(r) Discussion on behalf of Zdaniuk, Bozena
Sent: Tue 10/23/2007 11:44 AM
To: [hidden email]
Subject: 'replace' does not work on new text



Hello, I am using spss 15 and I just ran into this problem:

When I copy and paste some text within a syntax file and then want to use the find-and-replace function, it does not recognize (find) the newly copied text. I need to save and re-open, sometimes more than once, the syntax file for the find-and-replace function to recognize the new text. Is this a bug? Is there a patch for it?
Thanks, everyone.
Bozena

Bozena Zdaniuk, Ph.D.
University of Pittsburgh
UCSUR, 6th Fl.
121 University Place
Pittsburgh, PA 15260
Ph.: 412-624-5736
Fax: 412-624-4810
Email: [hidden email]

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

=====================
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: 'replace' does not work on new text

Florio Arguillas
In reply to this post by Zdaniuk, Bozena-2
Hi Bozena,

Read my response to the Ctrl-F bug question earlier today. It is a
bug.  There is a workaround.  And it should be history by now with
the advent of SPSS version 16.

Best regards,

Florio




At 12:44 PM 10/23/2007, you wrote:

>Hello, I am using spss 15 and I just ran into this problem:
>
>When I copy and paste some text within a syntax file and then want
>to use the find-and-replace function, it does not recognize (find)
>the newly copied text. I need to save and re-open, sometimes more
>than once, the syntax file for the find-and-replace function to
>recognize the new text. Is this a bug? Is there a patch for it?
>Thanks, everyone.
>Bozena
>
>Bozena Zdaniuk, Ph.D.
>University of Pittsburgh
>UCSUR, 6th Fl.
>121 University Place
>Pittsburgh, PA 15260
>Ph.: 412-624-5736
>Fax: 412-624-4810
>Email: [hidden email]
>
>=====================
>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

=====================
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: IF THEN

Hal 9000
In reply to this post by Lacay, Phebe
lose the "then"s. Also, it looks like CNTY is a string variable, so
"missing" would be an empty string ( '' ).

If any(CNTY, '', '999') & STATE = '99' CNTY= '00'.
If any(CNTY, '', '999') & STATE = '99' then CNTY='00'.
If any(CNTY, '', '999') & STATE = '34' then CNTY='88.
exe.

good luck!
-Gary

On 10/23/07, Lacay, Phebe <[hidden email]> wrote:

> Hi all,
>
> It's me again.
>
>
>
> I am trying to do a recode.  I am not sure if I should be doing a DO
> IF??
>
> Any suggestions?
>
>
>
> (all are string)
>
> If CNTY=missing or '999' and STATE= '99' then CNTY='00'
>
> If CNTY=missing or '999' and STATE='34' then CNTY='88
>
> If CNTY=missing or '999' and STATE~='34' then CNTY='99'
>
>
>
> Thanks,
>
> Phebe
>
>
>
>
>
> 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
>

=====================
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: IF THEN

Hal 9000
....as I said, lose the "then"s....
>
> If any(CNTY, '', '999') & STATE = '99' CNTY= '00'.
> If any(CNTY, '', '999') & STATE = '34' CNTY='88.
> exe.

=====================
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: IF THEN

Richard Ristow
In reply to this post by Lacay, Phebe
At 12:13 PM 10/23/2007, Lacay, Phebe wrote:

>I am trying to do a recode.  I am not sure if I should be doing a DO
>IF??
>
>If CNTY=missing or '999' and STATE= '99' then CNTY='00'
>If CNTY=missing or '999' and STATE='34' then CNTY='88
>If CNTY=missing or '999' and STATE~='34' then CNTY='99'

Gary's advice

>lose the "then"s. Also, it looks like CNTY is a string variable, so
>"missing" would be an empty string ( '' ).
>
>If any(CNTY, '', '999') & STATE = '99' CNTY= '00'.
>If any(CNTY, '', '999') & STATE = '99' then CNTY='00'.
>If any(CNTY, '', '999') & STATE = '34' then CNTY='88.

is exactly on. Here are some stylistic points I'd recommend. I think
they make the code more readable, and hence more reliable: it's easier
to spot mistakes like

. The test for STATE='99' is repeated
. There's no closing apostrophe on your '88'.


A. If CNTY is 8 characters or less, or you're running SPSS 16, then if
blank and '999' values for CNTY always denote missing data, define them
as user-missing values - that's what user-missing values are for:

MISSING VALUES CNTY ('','999').

B. All your IFs test for missing county data. I'd test that once, in a
DO IF that wraps all your other tests:

DO IF any(CNTY, '', '999').
.  If STATE = '99' CNTY= '00'.
.  If STATE = '99' CNTY='00'.
.  If STATE = '34' CNTY='88.
END IF.

With user-missing values for CNTY, it can be yet more readable:

DO IF MISSING(CNTY).
(etc.)

C. Having done the above, I'd suggest writing the rest of the tests
with the very powerful SPSS statement "RECODE":

DO IF any(CNTY, '', '999').
.  RECODE STATE
         ('99' = '00')
         ('34' = '88')
    INTO CNTY.
END IF.

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