using lag function

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

using lag function

Raffe, Sydelle, SSA

This seems like the simplest syntax and I’ve run many a statement like this. But I continue to get the error message below. Checked the parens, added parens, etc. I can’t see the problem. StoreCounty is numericand; id_pgm is string. Is that the problem? TIA.

 

 

if missing(storecounty) and id_pgm eq lag(id_pgm) storecounty = lag(storecounty).

 

 

>Error # 4007 in column 52.  Text: storecounty

>The expression is incomplete.  Check for missing operands, invalid

>operators, unmatched parentheses or excessive string length.

>This command not executed.

Reply | Threaded
Open this post in threaded view
|

Re: using lag function

Art Kendall
check whether the line before it end with a period.

Art


On 10/20/2010 2:25 PM, Raffe, Sydelle, SSA wrote:

This seems like the simplest syntax and I’ve run many a statement like this. But I continue to get the error message below. Checked the parens, added parens, etc. I can’t see the problem. StoreCounty is numericand; id_pgm is string. Is that the problem? TIA.

 

 

if missing(storecounty) and id_pgm eq lag(id_pgm) storecounty = lag(storecounty).

 

 

>Error # 4007 in column 52.  Text: storecounty

>The expression is incomplete.  Check for missing operands, invalid

>operators, unmatched parentheses or excessive string length.

>This command not executed.

===================== 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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: using lag function

Bruce Weaver
Administrator
In reply to this post by Raffe, Sydelle, SSA
Raffe, Sydelle, SSA wrote
This seems like the simplest syntax and I've run many a statement like this. But I continue to get the error message below. Checked the parens, added parens, etc. I can't see the problem. StoreCounty is numericand; id_pgm is string. Is that the problem? TIA.


if missing(storecounty) and id_pgm eq lag(id_pgm) storecounty = lag(storecounty).


>Error # 4007 in column 52.  Text: storecounty
>The expression is incomplete.  Check for missing operands, invalid
>operators, unmatched parentheses or excessive string length.
>This command not executed.
I don't see anything wrong.  The following worked for me:

data list free / id_pgm (a3) storecounty (f5.0).
begin data
aaa 1
aaa .
bbb 2
bbb 2
bbb .
ccc 3
ccc .
end data.

list.
if missing(storecounty) and
   ltrim(rtrim(id_pgm)) eq ltrim(rtrim(lag(id_pgm))) storecounty = lag(storecounty).
list.

Your original IF statement worked too--I just added the LTRIM and RTRIM functions because it's often a good precaution when working with string ID variables.

--
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: using lag function

Raffe, Sydelle, SSA
In reply to this post by Art Kendall

Thanks. Period is in place.

 


From: Art Kendall [mailto:[hidden email]]
Sent: Wednesday, October 20, 2010 11:45 AM
To: Raffe, Sydelle, SSA
Cc: [hidden email]
Subject: Re: [SPSSX-L] using lag function

 

check whether the line before it end with a period.

Art


On 10/20/2010 2:25 PM, Raffe, Sydelle, SSA wrote:

This seems like the simplest syntax and I’ve run many a statement like this. But I continue to get the error message below. Checked the parens, added parens, etc. I can’t see the problem. StoreCounty is numericand; id_pgm is string. Is that the problem? TIA.

 

 

if missing(storecounty) and id_pgm eq lag(id_pgm) storecounty = lag(storecounty).

 

 

>Error # 4007 in column 52.  Text: storecounty

>The expression is incomplete.  Check for missing operands, invalid

>operators, unmatched parentheses or excessive string length.

>This command not executed.

Reply | Threaded
Open this post in threaded view
|

Re: using lag function

Richard Ristow
In reply to this post by Raffe, Sydelle, SSA
At 02:25 PM 10/20/2010, Raffe, Sydelle, SSA wrote:

I continue to get the error message below. I can’t see the problem. StoreCounty is numericand; id_pgm is string. Is that the problem?
 
if missing(storecounty) and id_pgm eq lag(id_pgm) storecounty = lag(storecounty).
 
 
>Error # 4007 in column 52.  Text: storecounty
>The expression is incomplete.  Check for missing operands, invalid
>operators, unmatched parentheses or excessive string length.
>This command not executed.

To expand on what Art wrote: Often, whether a syntax error is reported depends partly on the context in which the code occurs.

Could you post you full program?

Do you have any test data you could post, as well?


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