About assigning

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

About assigning

fevziesen
Hi,

I could not find any syntax commands regarding my issue. Here:

a   3     5
a   3     .
b   6     3
b   6     .
b   6     .
c   2     1
c   3     1
c   3     .


for instance the first row indicates a vector with value (a,3,5). I want to assign "5" to the blank if (a,3) condition satisfies.. Again, I have a vector (b,6,3). I want to write "3" value till the condition (b,6) satisfies..


Thanks for your help in advance.
Reply | Threaded
Open this post in threaded view
|

Re: About assigning

Bruce Weaver
Administrator
If I follow you, this should do it (assuming the 3 variables in your example are V1 to V3).

IF MISSING(V3) V3 = LAG(V3).

If the data are not already sorted as you show below, use SORT CASES first.  I don't remember what happens with system missing values when you sort cases, so if it doesn't sort the way you expect, you'll have to change the sort order (i.e., A or D) for V3.  I.e., try this:

SORT CASES by V1 V2 V3.

If the SYSMIS values are appearing before the valid values, then try this:

SORT CASES by V1 V2 (A) V3 (D).

HTH.


fevziesen wrote
Hi,

I could not find any syntax commands regarding my issue. Here:

a   3     5
a   3     .
b   6     3
b   6     .
b   6     .
c   2     1
c   3     1
c   3     .


for instance the first row indicates a vector with value (a,3,5). I want to assign "5" to the blank if (a,3) condition satisfies.. Again, I have a vector (b,6,3). I want to write "3" value till the condition (b,6) satisfies..


Thanks for your help in advance.
--
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: About assigning

David Marso
Administrator
Just in case I would protect that with
IF (  (v2 EQ LAG(v2) ) AND MISSING(v3)  )  v3 = LAG(v3).
IIRC :sysmis goes to the top, so (D) on SORT would apply.
--
Bruce Weaver wrote
If I follow you, this should do it (assuming the 3 variables in your example are V1 to V3).

IF MISSING(V3) V3 = LAG(V3).

If the data are not already sorted as you show below, use SORT CASES first.  I don't remember what happens with system missing values when you sort cases, so if it doesn't sort the way you expect, you'll have to change the sort order (i.e., A or D) for V3.  I.e., try this:

SORT CASES by V1 V2 V3.

If the SYSMIS values are appearing before the valid values, then try this:

SORT CASES by V1 V2 (A) V3 (D).

HTH.


fevziesen wrote
Hi,

I could not find any syntax commands regarding my issue. Here:

a   3     5
a   3     .
b   6     3
b   6     .
b   6     .
c   2     1
c   3     1
c   3     .


for instance the first row indicates a vector with value (a,3,5). I want to assign "5" to the blank if (a,3) condition satisfies.. Again, I have a vector (b,6,3). I want to write "3" value till the condition (b,6) satisfies..


Thanks for your help in advance.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: About assigning

Bruce Weaver
Administrator
Good call.  Depending on what the data look like, maybe even:

IF (  (v1 EQ LAG(v1) ) AND (v2 EQ LAG(v2) ) AND MISSING(v3)  )  v3 = LAG(v3).


David Marso wrote
Just in case I would protect that with
IF (  (v2 EQ LAG(v2) ) AND MISSING(v3)  )  v3 = LAG(v3).
IIRC :sysmis goes to the top, so (D) on SORT would apply.
--
Bruce Weaver wrote
If I follow you, this should do it (assuming the 3 variables in your example are V1 to V3).

IF MISSING(V3) V3 = LAG(V3).

If the data are not already sorted as you show below, use SORT CASES first.  I don't remember what happens with system missing values when you sort cases, so if it doesn't sort the way you expect, you'll have to change the sort order (i.e., A or D) for V3.  I.e., try this:

SORT CASES by V1 V2 V3.

If the SYSMIS values are appearing before the valid values, then try this:

SORT CASES by V1 V2 (A) V3 (D).

HTH.


fevziesen wrote
Hi,

I could not find any syntax commands regarding my issue. Here:

a   3     5
a   3     .
b   6     3
b   6     .
b   6     .
c   2     1
c   3     1
c   3     .


for instance the first row indicates a vector with value (a,3,5). I want to assign "5" to the blank if (a,3) condition satisfies.. Again, I have a vector (b,6,3). I want to write "3" value till the condition (b,6) satisfies..


Thanks for your help in advance.
--
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: About assigning

David Marso
Administrator
Yeah, I was leaving that to OP to factor in if things went FUBie.
--
Bruce Weaver wrote
Good call.  Depending on what the data look like, maybe even:

IF (  (v1 EQ LAG(v1) ) AND (v2 EQ LAG(v2) ) AND MISSING(v3)  )  v3 = LAG(v3).


David Marso wrote
Just in case I would protect that with
IF (  (v2 EQ LAG(v2) ) AND MISSING(v3)  )  v3 = LAG(v3).
IIRC :sysmis goes to the top, so (D) on SORT would apply.
--
Bruce Weaver wrote
If I follow you, this should do it (assuming the 3 variables in your example are V1 to V3).

IF MISSING(V3) V3 = LAG(V3).

If the data are not already sorted as you show below, use SORT CASES first.  I don't remember what happens with system missing values when you sort cases, so if it doesn't sort the way you expect, you'll have to change the sort order (i.e., A or D) for V3.  I.e., try this:

SORT CASES by V1 V2 V3.

If the SYSMIS values are appearing before the valid values, then try this:

SORT CASES by V1 V2 (A) V3 (D).

HTH.


fevziesen wrote
Hi,

I could not find any syntax commands regarding my issue. Here:

a   3     5
a   3     .
b   6     3
b   6     .
b   6     .
c   2     1
c   3     1
c   3     .


for instance the first row indicates a vector with value (a,3,5). I want to assign "5" to the blank if (a,3) condition satisfies.. Again, I have a vector (b,6,3). I want to write "3" value till the condition (b,6) satisfies..


Thanks for your help in advance.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"
Reply | Threaded
Open this post in threaded view
|

Re: About assigning

fevziesen
Thnaks for your help but I have an error : transformations pending and also tried execute command. It never responded.

Here is my all code:


DATASET ACTIVATE DataSet2.
IF ((NAME EQ LAG(NAME)) AND (DATE EQ LAG(DATE)) AND (MISSING (VOL))) VOL=LAG(VOL)







Reply | Threaded
Open this post in threaded view
|

Re: About assigning

Bruce Weaver
Administrator
You need a command terminator on the IF line.  

IF ((NAME EQ LAG(NAME)) AND (DATE EQ LAG(DATE)) AND (MISSING (VOL))) VOL=LAG(VOL).


fevziesen wrote
Thnaks for your help but I have an error : transformations pending and also tried execute command. It never responded.

Here is my all code:


DATASET ACTIVATE DataSet2.
IF ((NAME EQ LAG(NAME)) AND (DATE EQ LAG(DATE)) AND (MISSING (VOL))) VOL=LAG(VOL)
--
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/).