simple help

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

simple help

Ben Haysom-Newport
Hi Folks

I have a really simple job I need very quick help with and I can't find it!

I need to create a new variable based on logic IF > 17.54. Just need
the new variable to return yes or 1 for a true if otherwise a no or 0.

Can someone help me?

--
Many thanks
Ben Haysom-Newport MSc
Regard Co-Chair (Male)
www.regard.org.uk
www.haysom-newport.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: simple help

Ben Haysom-Newport
Thank you! Life saver!

On 17 August 2010 13:15, William Dudley <[hidden email]> wrote:

> compute newvar = 0.
> if oldvar > 17.54 newvar =1.
> EXECUTE.
>
> Then I would double check with a cross tab
>
> CROSSTABS
>   /TABLES=oldvar BY newvar
>   /FORMAT=AVALUE TABLES
>   /CELLS=COUNT
>   /COUNT ROUND CELL.
>
>
> On Tue, Aug 17, 2010 at 8:07 AM, Ben Haysom-Newport <[hidden email]>
> wrote:
>>
>> Hi Folks
>>
>> I have a really simple job I need very quick help with and I can't find
>> it!
>>
>> I need to create a new variable based on logic IF > 17.54. Just need
>> the new variable to return yes or 1 for a true if otherwise a no or 0.
>>
>> Can someone help me?
>>
>> --
>> Many thanks
>> Ben Haysom-Newport MSc
>> Regard Co-Chair (Male)
>> www.regard.org.uk
>> www.haysom-newport.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
>
>
>
> --
> William N. Dudley, PhD
> Associate Dean for Research
> The School of Health and Human Performance Office of Research
> The University of North Carolina at Greensboro
> 126 HHP Building, PO Box 26170
> Greensboro, NC 27402-6170
> VOICE 336.2562475
> FAX 336.334.3238
>



--
Many thanks
Ben Haysom-Newport MSc
Regard Co-Chair (Male)
www.regard.org.uk
www.haysom-newport.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: simple help

Samir Paul-2
In reply to this post by Ben Haysom-Newport
The simple syntax should look like something as below:
 
compute xgt175 = 0.
if ( oldvar gt 17.5) xgt175 = 1.
execute.
 
HTH.
 
samir


From: Ben Haysom-Newport <[hidden email]>
To: [hidden email]
Sent: Tue, August 17, 2010 5:07:43 AM
Subject: simple help

Hi Folks

I have a really simple job I need very quick help with and I can't find it!

I need to create a new variable based on logic IF > 17.54. Just need
the new variable to return yes or 1 for a true if otherwise a no or 0.

Can someone help me?

--
Many thanks
Ben Haysom-Newport MSc
Regard Co-Chair (Male)
www.regard.org.uk
www.haysom-newport.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: simple help

Rick Oliver-3
Even simpler:

compute newvar=oldvar>17.5.


From: Samir Paul <[hidden email]>
To: [hidden email]
Date: 08/17/2010 07:23 AM
Subject: Re: simple help
Sent by: "SPSSX(r) Discussion" <[hidden email]>





The simple syntax should look like something as below:
 
compute xgt175 = 0.
if ( oldvar gt 17.5) xgt175 = 1.
execute.
 
HTH.
 
samir


From: Ben Haysom-Newport <[hidden email]>
To:
[hidden email]
Sent:
Tue, August 17, 2010 5:07:43 AM
Subject:
simple help


Hi Folks

I have a really simple job I need very quick help with and I can't find it!

I need to create a new variable based on logic IF > 17.54. Just need
the new variable to return yes or 1 for a true if otherwise a no or 0.

Can someone help me?

--
Many thanks
Ben Haysom-Newport MSc
Regard Co-Chair (Male)
www.regard.org.uk
www.haysom-newport.com

=====================
To manage your subscription to SPSSX-L, send a message to

LISTSERV@... (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: simple help

Bruce Weaver
Administrator
Rick Oliver wrote
Even simpler:

compute newvar=oldvar>17.5.

From: Samir Paul <paulsamir.2009@yahoo.ca>
To: SPSSX-L@LISTSERV.UGA.EDU
Date: 08/17/2010 07:23 AM
Subject: Re: simple help
Sent by: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>

The simple syntax should look like something as below:

compute xgt175 = 0.
if ( oldvar gt 17.5) xgt175 = 1.
execute.

Notice that the two methods will give different results if OLDVAR is missing.  For Rick's one-line solution, if OLDVAR is missing, then NEWVAR will also be missing.  But if you use Samir's solution, XGT175 will be set to 0 (false) for all cases, even if OLDVAR is missing.

--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: simple help

Rick Oliver-3
Good point.  In general, I prefer the result to be set to missing if the condition I'm testing resolves to missing. A missing value is neither greater than nor less than (nor equal to) the test condition. It is unknown. It could be any of them.


From: Bruce Weaver <[hidden email]>
To: [hidden email]
Date: 08/17/2010 09:35 AM
Subject: Re: simple help
Sent by: "SPSSX(r) Discussion" <[hidden email]>





Rick Oliver wrote:
>
> Even simpler:
>
> compute newvar=oldvar>17.5.
>
> From: Samir Paul <[hidden email]>
> To: [hidden email]
> Date: 08/17/2010 07:23 AM
> Subject: Re: simple help
> Sent by: "SPSSX(r) Discussion" <[hidden email]>
>
> The simple syntax should look like something as below:
>
> compute xgt175 = 0.
> if ( oldvar gt 17.5) xgt175 = 1.
> execute.
>
>


Notice that the two methods will give different results if OLDVAR is
missing.  For Rick's one-line solution, if OLDVAR is missing, then NEWVAR
will also be missing.  But if you use Samir's solution, XGT175 will be set
to 0 (false) for all cases, even if OLDVAR is missing.



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

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/simple-help-tp2638043p2638226.html
Sent from the SPSSX Discussion mailing list archive at 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