Re: question

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

Re: question

John F Hall

Joanna

 

Is your variable called STATES or STATES_2011?

 

Shouldn’t “in” be “=”?

 

Try:

 

recode STATE_2011 ("VA","MI","IL” =1)(else = 0) into newstate.

freq newstate.

 

Always best to ask the SPSS list in case I’m not here, so copied this to list.

 

John

 

 

John F Hall (Mr)

[Retired academic survey researcher]

 

Email:   [hidden email] 

Website: www.surveyresearch.weebly.com

Start page:  www.surveyresearch.weebly.com/spss-without-tears.html

  

 

 

 

 

From: Joanna Koh [mailto:[hidden email]]
Sent: 24 April 2013 15:58
To: John F Hall
Subject: RE: question

 

John,

I have a field called "STATES" and there are 50 states within the field. I am choosing a few states in my DO IF and could you look at the syntax below and tell me if there is a better way of writing STATE_2011 in ("VA","MI","IL")? It is running a long time and I am not sure how to make it run quickly.  Thanks a lot!!  Joanna

 

DO IF (STATE_2011 in ( "VA","MI","IL")).
COMPUTE STATE=1.
ELSE.
COMPUTE STATE=0.
END IF.
EXECUTE.

 

Reply | Threaded
Open this post in threaded view
|

Re: question

Antoon Smulders

Maybe::

DO IF ANY(state_2011, “VA”, “MI”, “IL”).

COMPUTE STATE=1.
ELSE.
COMPUTE STATE=0.
END IF.

 

Or even shorter:

COMPUTE State = ANY (state_2011, “VA”, “MI”, “IL”).

 

Execute.

Execute.

Execute.

J

 

 

Van: SPSSX(r) Discussion [mailto:[hidden email]] Namens John F Hall
Verzonden: woensdag 24 april 2013 18:46
Aan: [hidden email]
Onderwerp: Re: question

 

Joanna

 

Is your variable called STATES or STATES_2011?

 

Shouldn’t “in” be “=”?

 

Try:

 

recode STATE_2011 ("VA","MI","IL” =1)(else = 0) into newstate.

freq newstate.

 

Always best to ask the SPSS list in case I’m not here, so copied this to list.

 

John

 

 

John F Hall (Mr)

[Retired academic survey researcher]

 

Email:   [hidden email] 

Website: www.surveyresearch.weebly.com

Start page:  www.surveyresearch.weebly.com/spss-without-tears.html

  

 

 

 

 

From: Joanna Koh [mailto:[hidden email]]
Sent: 24 April 2013 15:58
To: John F Hall
Subject: RE: question

 

John,

I have a field called "STATES" and there are 50 states within the field. I am choosing a few states in my DO IF and could you look at the syntax below and tell me if there is a better way of writing STATE_2011 in ("VA","MI","IL")? It is running a long time and I am not sure how to make it run quickly.  Thanks a lot!!  Joanna

 

DO IF (STATE_2011 in ( "VA","MI","IL")).
COMPUTE STATE=1.
ELSE.
COMPUTE STATE=0.
END IF.
EXECUTE.