Create set of variables in LOOP (odd error)

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

Create set of variables in LOOP (odd error)

bc
Hi Folks, I am trying to write one set of new variables based on data from two sets of variables. Basically, I'm reading each set and then writing to the new variables. Note that where missing data exist in set 1, data are available in set 2, and the new variables will result in a complete matrix. PROBLEM: Set 2 values are not written to data file. Why? Here's my code: data list list/ad101 ad102 ad103 ad104 ds101 ds102 ds103 ds104 (8f3). begin data 2 . 4 5 . 2 . . 1 2 . 6 . . 5 . 4 6 . . . . 6 7 end data. EXECUTE. vector STEMactiv(4). /* generate new vars. vector STEM_=ad101 to ad104. /*process Set 1 and write to new vars. LOOP #=1 to 4. COMPUTE STEMactiv(#)=STEM_(#). END LOOP. vector STEMb_=ds101 to ds104. /*process Set 2 and write to new vars. LOOP #=1 to 4. COMPUTE STEMactiv(#)=STEMb_(#). END LOOP. EXECUTE. Note: In my full data set, Set 1 and Set 2 are not contiguous, so writing one LOOP isn't feasible. Thanks for ideas!
Reply | Threaded
Open this post in threaded view
|

Re: Create set of variables in LOOP (odd error)

David Marso
Administrator
Please post the desired outcome of this exercise as well as the existing result and why it is insufficient.
I'm done with the mind reading thing.
bc wrote
Hi Folks,
I am trying to write one set of new variables based on data from two sets of variables. Basically, I'm reading each set and then writing to the new variables. Note that where missing data exist in set 1, data are available in set 2, and the new variables will result in a complete matrix.

PROBLEM:  Set 2 values are not written to data file.  Why?

Here's my code:

data list list/ad101 ad102 ad103 ad104 ds101 ds102 ds103 ds104 (8f3).
begin data
2 . 4 5 . 2 . .
1 2 . 6 . . 5 .
4 6 . . . . 6 7
end data.
EXECUTE.

vector STEMactiv(4).   /* generate new vars.

vector STEM_=ad101 to ad104. /*process Set 1 and write to new vars.
LOOP #=1 to 4.
COMPUTE STEMactiv(#)=STEM_(#).
END LOOP.

vector STEMb_=ds101 to ds104. /*process Set 2 and write to new vars.
LOOP #=1 to 4.
COMPUTE STEMactiv(#)=STEMb_(#).
END LOOP.
EXECUTE.


Note: In my full data set, Set 1 and Set 2 are not contiguous, so writing one LOOP isn't feasible.

Thanks for ideas!
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: Create set of variables in LOOP (odd error)

Rich Ulrich

Are you sure you are looking at that right?


Not showing Set 2 is an odd problem, because the code says that Set 2 should totally replace Set 1.

The one-line fix for the problem that I think you have is to replace the second loop's COMPUTE with --

IF  MISS(STEMactiv(#)  STEMactiv(#)=STEMb_(#).

If you define both vectors at the same time, you can put both assignments in one loop.

--
Rich Ulrich


From: SPSSX(r) Discussion <[hidden email]> on behalf of David Marso <[hidden email]>
Sent: Wednesday, December 7, 2016 12:32 PM
To: [hidden email]
Subject: Re: Create set of variables in LOOP (odd error)
 
Please post the desired outcome of this exercise as well as the existing
result and why it is insufficient.
I'm done with the mind reading thing.

bc wrote
> Hi Folks,
> I am trying to write one set of new variables based on data from two sets
> of variables. Basically, I'm reading each set and then writing to the new
> variables. Note that where missing data exist in set 1, data are available
> in set 2, and the new variables will result in a complete matrix.
>
> PROBLEM:  Set 2 values are not written to data file.  Why?
>
> Here's my code:
>
> data list list/ad101 ad102 ad103 ad104 ds101 ds102 ds103 ds104 (8f3).
> begin data
> 2 . 4 5 . 2 . .
> 1 2 . 6 . . 5 .
> 4 6 . . . . 6 7
> end data.
> EXECUTE.
>
> vector STEMactiv(4).   /* generate new vars.
>
> vector STEM_=ad101 to ad104.          /*process Set 1 and write to new vars.
> LOOP #=1 to 4.
> COMPUTE STEMactiv(#)=STEM_(#).
> END LOOP.
>
> vector STEMb_=ds101 to ds104.         /*process Set 2 and write to new vars.
> LOOP #=1 to 4.
> COMPUTE STEMactiv(#)=STEMb_(#).
> END LOOP.
> EXECUTE.
>
>
> Note: In my full data set, Set 1 and Set 2 are not contiguous, so writing
> one LOOP isn't feasible.
>
> Thanks for ideas!





-----
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?"
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Create-set-of-variables-in-LOOP-odd-error-tp5733571p5733572.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
===================== 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: Create set of variables in LOOP (odd error)

David Marso
Administrator
In reply to this post by David Marso
OK, now seeing it with proper breaks (in Nabble original is one long run on Kos.).

DO REPEAT ad= ad101 TO ad104 / ds=ds101 TO ds104 /STEMactiv=STEMactiv1 TO STEMactiv4.
COMPUTE STEMactiv=MAX(ad,ds).
END REPEAT.

That's all folks...


David Marso wrote
Please post the desired outcome of this exercise as well as the existing result and why it is insufficient.
I'm done with the mind reading thing.
bc wrote
Hi Folks,
I am trying to write one set of new variables based on data from two sets of variables. Basically, I'm reading each set and then writing to the new variables. Note that where missing data exist in set 1, data are available in set 2, and the new variables will result in a complete matrix.

PROBLEM:  Set 2 values are not written to data file.  Why?

Here's my code:

data list list/ad101 ad102 ad103 ad104 ds101 ds102 ds103 ds104 (8f3).
begin data
2 . 4 5 . 2 . .
1 2 . 6 . . 5 .
4 6 . . . . 6 7
end data.
EXECUTE.

vector STEMactiv(4).   /* generate new vars.

vector STEM_=ad101 to ad104. /*process Set 1 and write to new vars.
LOOP #=1 to 4.
COMPUTE STEMactiv(#)=STEM_(#).
END LOOP.

vector STEMb_=ds101 to ds104. /*process Set 2 and write to new vars.
LOOP #=1 to 4.
COMPUTE STEMactiv(#)=STEMb_(#).
END LOOP.
EXECUTE.


Note: In my full data set, Set 1 and Set 2 are not contiguous, so writing one LOOP isn't feasible.

Thanks for ideas!
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?"
bc
Reply | Threaded
Open this post in threaded view
|

Re: Create set of variables in LOOP (odd error)

bc
Rather slick, Dave....thanks....
bc
Reply | Threaded
Open this post in threaded view
|

Re: Create set of variables in LOOP (odd error)

bc
In reply to this post by Rich Ulrich
Thanks Rich....  
Reply | Threaded
Open this post in threaded view
|

Re: Create set of variables in LOOP (odd error)

Rich Ulrich
In reply to this post by David Marso

Dave - Same here, all one long run in Outlook Mail.  Sometimes that used to go away

(recent changes may matter) when I looked at the message in Reply.  But this time

it did not.  That is why I wrote my Reply as a Reply to your Reply -- it showed the lines.


--

Rich Ulrich




From: SPSSX(r) Discussion <[hidden email]> on behalf of David Marso <[hidden email]>
Sent: Wednesday, December 7, 2016 1:59 PM
To: [hidden email]
Subject: Re: Create set of variables in LOOP (odd error)
 
OK, now seeing it with proper breaks (in Nabble original is one long run on
Kos.).


===================== 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: Create set of variables in LOOP (odd error)

Bruce Weaver
Administrator
FWIW, using the "Quote" button when replying in Nabble fixes it too.

bc wrote
Here's my code:

data list list/ad101 ad102 ad103 ad104 ds101 ds102 ds103 ds104 (8f3).
begin data
2 . 4 5 . 2 . .
1 2 . 6 . . 5 .
4 6 . . . . 6 7
end data.
EXECUTE.

vector STEMactiv(4).   /* generate new vars.

vector STEM_=ad101 to ad104. /*process Set 1 and write to new vars.
LOOP #=1 to 4.
COMPUTE STEMactiv(#)=STEM_(#).
END LOOP.

vector STEMb_=ds101 to ds104. /*process Set 2 and write to new vars.
LOOP #=1 to 4.
COMPUTE STEMactiv(#)=STEMb_(#).
END LOOP.
EXECUTE.
Rich Ulrich wrote
Dave - Same here, all one long run in Outlook Mail.  Sometimes that used to go away

(recent changes may matter) when I looked at the message in Reply.  But this time

it did not.  That is why I wrote my Reply as a Reply to your Reply -- it showed the lines.


--

Rich Ulrich


________________________________
From: SPSSX(r) Discussion <[hidden email]> on behalf of David Marso <[hidden email]>
Sent: Wednesday, December 7, 2016 1:59 PM
To: [hidden email]
Subject: Re: Create set of variables in LOOP (odd error)

OK, now seeing it with proper breaks (in Nabble original is one long run on
Kos.).



=====================
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
--
Bruce Weaver
bweaver@lakeheadu.ca
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.
Reply | Threaded
Open this post in threaded view
|

Re: Create set of variables in LOOP (odd error)

David Marso
Administrator
That's what I do.  "Quote"

On Thu, Dec 8, 2016 at 9:56 AM, Bruce Weaver [via SPSSX Discussion] <[hidden email]> wrote:
FWIW, using the "Quote" button when replying in Nabble fixes it too.

bc wrote
Here's my code:

data list list/ad101 ad102 ad103 ad104 ds101 ds102 ds103 ds104 (8f3).
begin data
2 . 4 5 . 2 . .
1 2 . 6 . . 5 .
4 6 . . . . 6 7
end data.
EXECUTE.

vector STEMactiv(4).   /* generate new vars.

vector STEM_=ad101 to ad104. /*process Set 1 and write to new vars.
LOOP #=1 to 4.
COMPUTE STEMactiv(#)=STEM_(#).
END LOOP.

vector STEMb_=ds101 to ds104. /*process Set 2 and write to new vars.
LOOP #=1 to 4.
COMPUTE STEMactiv(#)=STEMb_(#).
END LOOP.
EXECUTE.
Rich Ulrich wrote
Dave - Same here, all one long run in Outlook Mail.  Sometimes that used to go away

(recent changes may matter) when I looked at the message in Reply.  But this time

it did not.  That is why I wrote my Reply as a Reply to your Reply -- it showed the lines.


--

Rich Ulrich


________________________________
From: SPSSX(r) Discussion <[hidden email]> on behalf of David Marso <[hidden email]>
Sent: Wednesday, December 7, 2016 1:59 PM
To: [hidden email]
Subject: Re: Create set of variables in LOOP (odd error)

OK, now seeing it with proper breaks (in Nabble original is one long run on
Kos.).



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



If you reply to this email, your message will be added to the discussion below:
http://spssx-discussion.1045642.n5.nabble.com/Create-set-of-variables-in-LOOP-odd-error-tp5733571p5733581.html
To unsubscribe from Create set of variables in LOOP (odd error), click here.
NAML

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?"