if statement syntax

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

if statement syntax

Niki Thorne-Dolan
  Hiya,
  I am trying to convert the following sas code into SPSS to pick out a region from a postcode and need some guidance on syntax.


  if (((1*substr(upcase(postcode),2,1) in (1,2,3,4,5,6,7,8,9,0)) and (substr(upcase(postcode),1,1) in ('E','N','W'))) or (substr(upcase(postcode),1,2) in ('EC','NW','SE','SW','WC')) london=1.


  Thanks,
  Niki

 Send instant messages to your online friends http://uk.messenger.yahoo.com
Reply | Threaded
Open this post in threaded view
|

Re: if statement syntax

Edward Boadi
Try this :
Untested.

if ANY(substr(upcase(postcode),2,1),1,2,3,4,5,6,7,8,9,0)
   and
   ANY(substr(upcase(postcode),1,1),'E','N','W')
   or
   ANY(substr(upcase(postcode),1,2),'EC','NW','SE','SW','WC') london=1.


Edward.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Niki Thorne-Dolan
Sent: Wednesday, October 18, 2006 6:10 AM
To: [hidden email]
Subject: if statement syntax


  Hiya,
  I am trying to convert the following sas code into SPSS to pick out a region from a postcode and need some guidance on syntax.


  if (((1*substr(upcase(postcode),2,1) in (1,2,3,4,5,6,7,8,9,0)) and (substr(upcase(postcode),1,1) in ('E','N','W'))) or (substr(upcase(postcode),1,2) in ('EC','NW','SE','SW','WC')) london=1.


  Thanks,
  Niki

 Send instant messages to your online friends http://uk.messenger.yahoo.com
Reply | Threaded
Open this post in threaded view
|

Re: if statement syntax

Spousta Jan
In reply to this post by Niki Thorne-Dolan
Even the numbers must be in apostrophes here:
if ANY(substr(upcase(postcode),2,1),'1','2','3','4', etc.

Greetings

Jan

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Edward Boadi
Sent: Wednesday, October 18, 2006 4:09 PM
To: [hidden email]
Subject: Re: if statement syntax

Try this :
Untested.

if ANY(substr(upcase(postcode),2,1),1,2,3,4,5,6,7,8,9,0)
   and
   ANY(substr(upcase(postcode),1,1),'E','N','W')
   or
   ANY(substr(upcase(postcode),1,2),'EC','NW','SE','SW','WC') london=1.


Edward.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Niki Thorne-Dolan
Sent: Wednesday, October 18, 2006 6:10 AM
To: [hidden email]
Subject: if statement syntax


  Hiya,
  I am trying to convert the following sas code into SPSS to pick out a
region from a postcode and need some guidance on syntax.


  if (((1*substr(upcase(postcode),2,1) in (1,2,3,4,5,6,7,8,9,0)) and
(substr(upcase(postcode),1,1) in ('E','N','W'))) or
(substr(upcase(postcode),1,2) in ('EC','NW','SE','SW','WC')) london=1.


  Thanks,
  Niki

 Send instant messages to your online friends
http://uk.messenger.yahoo.com
Reply | Threaded
Open this post in threaded view
|

Re: if statement syntax

Niki Thorne-Dolan
In reply to this post by Edward Boadi
Thanks,

  I just changed the numerics to strings and it worked a treat.

  Thanks,

  Niki

Edward Boadi <[hidden email]> wrote:

Try this :
Untested.

if ANY(substr(upcase(postcode),2,1),1,2,3,4,5,6,7,8,9,0)
and
ANY(substr(upcase(postcode),1,1),'E','N','W')
or
ANY(substr(upcase(postcode),1,2),'EC','NW','SE','SW','WC') london=1.


Edward.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]]On Behalf Of
Niki Thorne-Dolan
Sent: Wednesday, October 18, 2006 6:10 AM
To: [hidden email]
Subject: if statement syntax


Hiya,
I am trying to convert the following sas code into SPSS to pick out a region from a postcode and need some guidance on syntax.


if (((1*substr(upcase(postcode),2,1) in (1,2,3,4,5,6,7,8,9,0)) and (substr(upcase(postcode),1,1) in ('E','N','W'))) or (substr(upcase(postcode),1,2) in ('EC','NW','SE','SW','WC')) london=1.


Thanks,
Niki

Send instant messages to your online friends http://uk.messenger.yahoo.com


 Send instant messages to your online friends http://uk.messenger.yahoo.com