Using a constant

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

Using a constant

Jeff A

 

I’m creating an example dataset for teaching purposes.

 

Within a long syntax file, I’m creating a number of variables with different distributions.

 

To make sure that I’ll be able to re-create the exact dataset if I make modifications, I’m using the Set Seed function in numerous places within the syntax file.

 

At some later point, I’ll likely want to create a different dataset (perhaps for next year’s students) with the same structure but different values.

 

Is there a way to do this easily without going through the entire syntax file and changing each of the many seeds by setting some type of constant at the beginning of the syntax that can be changed in one location? (or in some other way?)

 

 

E.g.,

 

Set Seed_Constant to 888.                  < I want to be able to change this value once and have it affect all of the seed values below.

 

Set Seed Seed_Constant + 89654 .

Compute X = rv.normal(100,5).

 

Set Seed Seed_Constant + 845654 .

Compute Y = rv.normal(50,15).

 

Set Seed Seed_Constant + 4654 .

Compute Z = rv.poisson(3).

 

Set Seed Seed_Constant + 958654 .

Compute A = rv.normal(500,50).

 

 

Jeff

 

===================== 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: Using a constant

Bruce Weaver
Administrator
My first thought was to use macros.  But of course, macro is just a string
parser, and cannot do arithmetic.  At least not directly.  But you can use
some trickery to coax it into doing arithmetic.  E.g., here is one way to do
addition:

        /* ------------------------------------------------------ */
        /* addition, using strings (!a + !b)                      */
        /* ------------------------------------------------------ */

        /* add !a and !b */
        !let !answer = !length(!concat(!blanks(!a), !blanks(!b)))
       

Source:
http://www.spsstools.net/en/macros/macros-index/macro-variables/doing-arithmetic-with-macro-variables/


Okay Jon...over to you.  Once you've calmed down sufficiently (after looking
at that macro code), show Jeff a nice way to do it with Python.  ;-)  




Jeff-2 wrote

> I'm creating an example dataset for teaching purposes.
>
>  
>
> Within a long syntax file, I'm creating a number of variables with
> different
> distributions.
>
>  
>
> To make sure that I'll be able to re-create the exact dataset if I make
> modifications, I'm using the Set Seed function in numerous places within
> the
> syntax file.
>
>  
>
> At some later point, I'll likely want to create a different dataset
> (perhaps
> for next year's students) with the same structure but different values.
>
>  
>
> Is there a way to do this easily without going through the entire syntax
> file and changing each of the many seeds by setting some type of constant
> at
> the beginning of the syntax that can be changed in one location? (or in
> some
> other way?)
>
>  
>
>  
>
> E.g.,
>
>  
>
> Set Seed_Constant to 888.                  < I want to be able to change
> this value once and have it affect all of the seed values below.
>
>  
>
> Set Seed Seed_Constant + 89654 .
>
> Compute X = rv.normal(100,5).
>
>  
>
> Set Seed Seed_Constant + 845654 .
>
> Compute Y = rv.normal(50,15).
>
>  
>
> Set Seed Seed_Constant + 4654 .
>
> Compute Z = rv.poisson(3).
>
>  
>
> Set Seed Seed_Constant + 958654 .
>
> Compute A = rv.normal(500,50).
>
>  
>
>  
>
> Jeff
>
>  
>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

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

--
Sent from: http://spssx-discussion.1045642.n5.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
--
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: Using a constant

Jon Peck
Ok, here's a Python way.  Note that the code below is using the old generator.  For higher quality random numbers, use the Mersenne Twister by executing
SET RNG = MT.
once at the top and then use
SET MTINDEX below instead of set seed.
I included a SHOW SEED command, but you cannot show the seed/state of the Mersenne Twister (it's 64K long!) so leave that out if you go that way.

Here's the code.
begin program.
import spss

# change this single value as desired.
SEED_CONSTANT = 888.
def adjust(increment):
    spss.SetMacroValue("!seed_constant", str(SEED_CONSTANT + increment))
end program.

* each call to the adjust function redefines the macro named !seed_constant.

begin program.
adjust(87654)
end program.

set seed !seed_constant.
show seed.

begin program.
adjust(845654),
end program.
set seed !seed_constant.
show seed. 

etc.

I am curious where these additive constants come from.

On Mon, Feb 25, 2019 at 4:31 PM Bruce Weaver <[hidden email]> wrote:
My first thought was to use macros.  But of course, macro is just a string
parser, and cannot do arithmetic.  At least not directly.  But you can use
some trickery to coax it into doing arithmetic.  E.g., here is one way to do
addition:

        /* ------------------------------------------------------ */
        /* addition, using strings (!a + !b)                      */
        /* ------------------------------------------------------ */

        /* add !a and !b */
        !let !answer = !length(!concat(!blanks(!a), !blanks(!b)))


Source:
http://www.spsstools.net/en/macros/macros-index/macro-variables/doing-arithmetic-with-macro-variables/


Okay Jon...over to you.  Once you've calmed down sufficiently (after looking
at that macro code), show Jeff a nice way to do it with Python.  ;-) 




Jeff-2 wrote
> I'm creating an example dataset for teaching purposes.
>

>
> Within a long syntax file, I'm creating a number of variables with
> different
> distributions.
>

>
> To make sure that I'll be able to re-create the exact dataset if I make
> modifications, I'm using the Set Seed function in numerous places within
> the
> syntax file.
>

>
> At some later point, I'll likely want to create a different dataset
> (perhaps
> for next year's students) with the same structure but different values.
>

>
> Is there a way to do this easily without going through the entire syntax
> file and changing each of the many seeds by setting some type of constant
> at
> the beginning of the syntax that can be changed in one location? (or in
> some
> other way?)
>

>

>
> E.g.,
>

>
> Set Seed_Constant to 888.                  < I want to be able to change
> this value once and have it affect all of the seed values below.
>

>
> Set Seed Seed_Constant + 89654 .
>
> Compute X = rv.normal(100,5).
>

>
> Set Seed Seed_Constant + 845654 .
>
> Compute Y = rv.normal(50,15).
>

>
> Set Seed Seed_Constant + 4654 .
>
> Compute Z = rv.poisson(3).
>

>
> Set Seed Seed_Constant + 958654 .
>
> Compute A = rv.normal(500,50).
>

>

>
> Jeff
>

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

> LISTSERV@.UGA

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

--
Sent from: http://spssx-discussion.1045642.n5.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


--
Jon K Peck
[hidden email]

===================== 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: Using a constant

Rick Oliver
In reply to this post by Jeff A
Note that if you want to duplicate all transformation distribution results or change them all, you just need to set the seed once, at the start of the syntax file. There is no need to explicitly set the seed for each transformation or block of transformations. So if you start with a file that just has a single seed specification at the start of the file, you just need to change that one setting to alter all transformation distribution results.

On Mon, Feb 25, 2019 at 4:03 PM Jeff <[hidden email]> wrote:

 

I’m creating an example dataset for teaching purposes.

 

Within a long syntax file, I’m creating a number of variables with different distributions.

 

To make sure that I’ll be able to re-create the exact dataset if I make modifications, I’m using the Set Seed function in numerous places within the syntax file.

 

At some later point, I’ll likely want to create a different dataset (perhaps for next year’s students) with the same structure but different values.

 

Is there a way to do this easily without going through the entire syntax file and changing each of the many seeds by setting some type of constant at the beginning of the syntax that can be changed in one location? (or in some other way?)

 

 

E.g.,

 

Set Seed_Constant to 888.                  < I want to be able to change this value once and have it affect all of the seed values below.

 

Set Seed Seed_Constant + 89654 .

Compute X = rv.normal(100,5).

 

Set Seed Seed_Constant + 845654 .

Compute Y = rv.normal(50,15).

 

Set Seed Seed_Constant + 4654 .

Compute Z = rv.poisson(3).

 

Set Seed Seed_Constant + 958654 .

Compute A = rv.normal(500,50).

 

 

Jeff

 

===================== 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: Using a constant

Jeff A

 

…yup,

 

…but if I want to create X and Y with the same distribution type that I can recreate on each run but also want X and Y to have values different from one another, I need to set a different seed value for X and Y. So it looks like Jon’s code does the trick.

 

 

 

From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Rick Oliver
Sent: Tuesday, 26 February 2019 10:53 AM
To: [hidden email]
Subject: Re: Using a constant

 

Note that if you want to duplicate all transformation distribution results or change them all, you just need to set the seed once, at the start of the syntax file. There is no need to explicitly set the seed for each transformation or block of transformations. So if you start with a file that just has a single seed specification at the start of the file, you just need to change that one setting to alter all transformation distribution results.

 

On Mon, Feb 25, 2019 at 4:03 PM Jeff <[hidden email]> wrote:

 

I’m creating an example dataset for teaching purposes.

 

Within a long syntax file, I’m creating a number of variables with different distributions.

 

To make sure that I’ll be able to re-create the exact dataset if I make modifications, I’m using the Set Seed function in numerous places within the syntax file.

 

At some later point, I’ll likely want to create a different dataset (perhaps for next year’s students) with the same structure but different values.

 

Is there a way to do this easily without going through the entire syntax file and changing each of the many seeds by setting some type of constant at the beginning of the syntax that can be changed in one location? (or in some other way?)

 

 

E.g.,

 

Set Seed_Constant to 888.                  < I want to be able to change this value once and have it affect all of the seed values below.

 

Set Seed Seed_Constant + 89654 .

Compute X = rv.normal(100,5).

 

Set Seed Seed_Constant + 845654 .

Compute Y = rv.normal(50,15).

 

Set Seed Seed_Constant + 4654 .

Compute Z = rv.poisson(3).

 

Set Seed Seed_Constant + 958654 .

Compute A = rv.normal(500,50).

 

 

Jeff

 

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

===================== 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: Using a constant

Jeff A
In reply to this post by Jon Peck

 

That works Jon, here’s my (example) modification of your code.

 

To answer your question about where the constants came from I listed before, I just made them up.

 

The idea was to create a dataset with a large number of different variables (perhaps 40 or more, only 2 are shown below) where I can re-create the existing values of the existing variables if I add more variables to it, but change all values of all variables by simply altering one seed number at the top of the syntax file if necessary. E.g., a) to give a different dataset to different students so the problems are all equally easy/difficult but each student’s answers will be different to other students or b) to alter the actual values (and thus answers) from year to year.

 

So the arbitrary “adjust” number below permits me to recreate these data if I add a Z variable later but just changing the single “SEED_CONSTANT” permits me to alter the values of an infinite number of variables at once to change the entire dataset.

 

 

Begin Program.

import spss

SEED_CONSTANT = 564.

def adjust(increment):

  spss.SetMacroValue("!seed_constant",str(SEED_CONSTANT + increment))

End Program.

 

Begin Program.

adjust(87654)

End Program.

Set seed !seed_constant.

Compute X = Rnd(rv.uniform(0,20),1) .

EXECUTE.

 

Begin Program.

adjust(9754)

End Program.

Set seed !seed_constant.

Compute Y = Rnd(rv.uniform(0,20),1) .

Exe.

 

Now X and Y have the distribution type but different values that are repeatable until the single SEED_CONSTANT is altered and then both change.

 

 

 

 

From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Jon Peck
Sent: Tuesday, 26 February 2019 9:58 AM
To: [hidden email]
Subject: Re: Using a constant

 

Ok, here's a Python way.  Note that the code below is using the old generator.  For higher quality random numbers, use the Mersenne Twister by executing

SET RNG = MT.

once at the top and then use

SET MTINDEX below instead of set seed.

I included a SHOW SEED command, but you cannot show the seed/state of the Mersenne Twister (it's 64K long!) so leave that out if you go that way.

 

Here's the code.

begin program.

import spss

 

# change this single value as desired.

SEED_CONSTANT = 888.

def adjust(increment):

    spss.SetMacroValue("!seed_constant", str(SEED_CONSTANT + increment))

end program.

 

* each call to the adjust function redefines the macro named !seed_constant.

 

begin program.

adjust(87654)

end program.

 

set seed !seed_constant.

show seed.

 

begin program.

adjust(845654),

end program.

set seed !seed_constant.

show seed. 

 

etc.

 

I am curious where these additive constants come from.

 

On Mon, Feb 25, 2019 at 4:31 PM Bruce Weaver <[hidden email]> wrote:

My first thought was to use macros.  But of course, macro is just a string
parser, and cannot do arithmetic.  At least not directly.  But you can use
some trickery to coax it into doing arithmetic.  E.g., here is one way to do
addition:

        /* ------------------------------------------------------ */
        /* addition, using strings (!a + !b)                      */
        /* ------------------------------------------------------ */

        /* add !a and !b */
        !let !answer = !length(!concat(!blanks(!a), !blanks(!b)))


Source:
http://www.spsstools.net/en/macros/macros-index/macro-variables/doing-arithmetic-with-macro-variables/


Okay Jon...over to you.  Once you've calmed down sufficiently (after looking
at that macro code), show Jeff a nice way to do it with Python.  ;-) 




Jeff-2 wrote


> I'm creating an example dataset for teaching purposes.
>

>
> Within a long syntax file, I'm creating a number of variables with
> different
> distributions.
>

>
> To make sure that I'll be able to re-create the exact dataset if I make
> modifications, I'm using the Set Seed function in numerous places within
> the
> syntax file.
>

>
> At some later point, I'll likely want to create a different dataset
> (perhaps
> for next year's students) with the same structure but different values.
>

>
> Is there a way to do this easily without going through the entire syntax
> file and changing each of the many seeds by setting some type of constant
> at
> the beginning of the syntax that can be changed in one location? (or in
> some
> other way?)
>

>

>
> E.g.,
>

>
> Set Seed_Constant to 888.                  < I want to be able to change
> this value once and have it affect all of the seed values below.
>

>
> Set Seed Seed_Constant + 89654 .
>
> Compute X = rv.normal(100,5).
>

>
> Set Seed Seed_Constant + 845654 .
>
> Compute Y = rv.normal(50,15).
>

>
> Set Seed Seed_Constant + 4654 .
>
> Compute Z = rv.poisson(3).
>

>
> Set Seed Seed_Constant + 958654 .
>
> Compute A = rv.normal(500,50).
>

>

>
> Jeff
>

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

--
Sent from: http://spssx-discussion.1045642.n5.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


 

--

Jon K Peck
[hidden email]

===================== 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: Using a constant

Rick Oliver
In reply to this post by Jeff A
Maybe I am misunderstanding what you are trying to accomplish, but unless you reset the seed to the same value between computing x and computing y, they will have different values within the same run for the same distribution, even with the same parameters. For example:

data list free /z.
begin data
1 2 3 4 5
end data.
set seed 12345.
compute x=rv.uniform(1,10).
compute y=rv.uniform(1,10).
list.

The seed changes for each transformation, but the initial seed determines how the seed will change for each subsequent transformation, until the seed is explicitly changed again.

So if you run that same syntax again, you will get the same values as the original run.

On Mon, Feb 25, 2019 at 7:01 PM Jeff <[hidden email]> wrote:

 

…yup,

 

…but if I want to create X and Y with the same distribution type that I can recreate on each run but also want X and Y to have values different from one another, I need to set a different seed value for X and Y. So it looks like Jon’s code does the trick.

 

 

 

From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Rick Oliver
Sent: Tuesday, 26 February 2019 10:53 AM
To: [hidden email]
Subject: Re: Using a constant

 

Note that if you want to duplicate all transformation distribution results or change them all, you just need to set the seed once, at the start of the syntax file. There is no need to explicitly set the seed for each transformation or block of transformations. So if you start with a file that just has a single seed specification at the start of the file, you just need to change that one setting to alter all transformation distribution results.

 

On Mon, Feb 25, 2019 at 4:03 PM Jeff <[hidden email]> wrote:

 

I’m creating an example dataset for teaching purposes.

 

Within a long syntax file, I’m creating a number of variables with different distributions.

 

To make sure that I’ll be able to re-create the exact dataset if I make modifications, I’m using the Set Seed function in numerous places within the syntax file.

 

At some later point, I’ll likely want to create a different dataset (perhaps for next year’s students) with the same structure but different values.

 

Is there a way to do this easily without going through the entire syntax file and changing each of the many seeds by setting some type of constant at the beginning of the syntax that can be changed in one location? (or in some other way?)

 

 

E.g.,

 

Set Seed_Constant to 888.                  < I want to be able to change this value once and have it affect all of the seed values below.

 

Set Seed Seed_Constant + 89654 .

Compute X = rv.normal(100,5).

 

Set Seed Seed_Constant + 845654 .

Compute Y = rv.normal(50,15).

 

Set Seed Seed_Constant + 4654 .

Compute Z = rv.poisson(3).

 

Set Seed Seed_Constant + 958654 .

Compute A = rv.normal(500,50).

 

 

Jeff

 

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

===================== 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: Using a constant

Jeff A

 

Yes. See my prior post. Jon figured out what I was trying to do even though my explanation wasn’t great and example code wasn’t anywhere close to being correct. I did need to change the seed for each variable within a particular dataset so these variables within the same dataset would contain different values, but also wanted to change *ALL* of the different seeds across multiple datasets that contained the same variables by simply changing a single “master-seed”.

 

J

 

 

 

 

 

 

From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Rick Oliver
Sent: Tuesday, 26 February 2019 1:42 PM
To: [hidden email]
Subject: Re: Using a constant

 

Maybe I am misunderstanding what you are trying to accomplish, but unless you reset the seed to the same value between computing x and computing y, they will have different values within the same run for the same distribution, even with the same parameters. For example:

 

data list free /z.

begin data

1 2 3 4 5

end data.

set seed 12345.

compute x=rv.uniform(1,10).

compute y=rv.uniform(1,10).

list.


The seed changes for each transformation, but the initial seed determines how the seed will change for each subsequent transformation, until the seed is explicitly changed again.

 

So if you run that same syntax again, you will get the same values as the original run.

 

On Mon, Feb 25, 2019 at 7:01 PM Jeff <[hidden email]> wrote:

 

…yup,

 

…but if I want to create X and Y with the same distribution type that I can recreate on each run but also want X and Y to have values different from one another, I need to set a different seed value for X and Y. So it looks like Jon’s code does the trick.

 

 

 

From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Rick Oliver
Sent: Tuesday, 26 February 2019 10:53 AM
To: [hidden email]
Subject: Re: Using a constant

 

Note that if you want to duplicate all transformation distribution results or change them all, you just need to set the seed once, at the start of the syntax file. There is no need to explicitly set the seed for each transformation or block of transformations. So if you start with a file that just has a single seed specification at the start of the file, you just need to change that one setting to alter all transformation distribution results.

 

On Mon, Feb 25, 2019 at 4:03 PM Jeff <[hidden email]> wrote:

 

I’m creating an example dataset for teaching purposes.

 

Within a long syntax file, I’m creating a number of variables with different distributions.

 

To make sure that I’ll be able to re-create the exact dataset if I make modifications, I’m using the Set Seed function in numerous places within the syntax file.

 

At some later point, I’ll likely want to create a different dataset (perhaps for next year’s students) with the same structure but different values.

 

Is there a way to do this easily without going through the entire syntax file and changing each of the many seeds by setting some type of constant at the beginning of the syntax that can be changed in one location? (or in some other way?)

 

 

E.g.,

 

Set Seed_Constant to 888.                  < I want to be able to change this value once and have it affect all of the seed values below.

 

Set Seed Seed_Constant + 89654 .

Compute X = rv.normal(100,5).

 

Set Seed Seed_Constant + 845654 .

Compute Y = rv.normal(50,15).

 

Set Seed Seed_Constant + 4654 .

Compute Z = rv.poisson(3).

 

Set Seed Seed_Constant + 958654 .

Compute A = rv.normal(500,50).

 

 

Jeff

 

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

===================== 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: Using a constant

Bruce Weaver
Administrator
Jeff-2 wrote
> Yes. See my prior post. Jon figured out what I was trying to do even
> though my explanation wasn’t great and example code wasn’t anywhere close
> to being correct. I did need to change the seed for each variable within a
> particular dataset so these variables within the same dataset would
> contain different values,

If you try Rick's code, or the modified version of it below, you'll see that
the variables v1 to v10 DO contain different values.  

data list free /z.
begin data
1 2 3 4 5
end data.
set seed 12345.
do repeat v = v1 to v10.
compute v=rv.uniform(1,10).
end repeat.
list.
descriptives all.



Jeff-2 wrote
> but also wanted to change *ALL* of the different seeds across multiple
> datasets that contained the same variables by simply changing a single
> “master-seed”.

If you re-run the code above with a different (master) seed value, you'll
get another dataset with different values in v1-v10, but also different from
the first dataset.  So like Rick, I don't understand the need to set
additional seeds beyond the initial "master" seed.  If Jon explained the
rationale somewhere, I missed it.  





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

--
Sent from: http://spssx-discussion.1045642.n5.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
--
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: Using a constant

Jeff A
You've got me curious so I ran a few tests. I'm unsure of the exact rules spss uses for resetting the seed, but apparently certain things cause the seed to revert back to a random number from the manually set one while other procedures don't.  The code below provides different results depending upon whether the descriptives output is run or left commented out in between the two computation of a and b. If the Desc a b line is not run, the show seed command produces 123456 both times. If it is run, it's altered for the second time.

It appears that as soon as I ask for output, the seed gets reset. I was doing that to test along the way, so I guess if I wasn't testing by asking for output, your version without Jon's complications would likely work just fine.




set seed 123456.
compute a=rv.uniform(1,10).
compute b=rv.uniform(1,10).
Show Seed.

 *  Desc a b .

compute a=rv.uniform(1,10).
compute b=rv.uniform(1,10).
Show Seed.
Desc a b.




-----Original Message-----
From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Bruce Weaver
Sent: Tuesday, 26 February 2019 10:31 PM
To: [hidden email]
Subject: Re: Using a constant

Jeff-2 wrote
> Yes. See my prior post. Jon figured out what I was trying to do even
> though my explanation wasn’t great and example code wasn’t anywhere
> close to being correct. I did need to change the seed for each
> variable within a particular dataset so these variables within the
> same dataset would contain different values,

If you try Rick's code, or the modified version of it below, you'll see that the variables v1 to v10 DO contain different values.  

data list free /z.
begin data
1 2 3 4 5
end data.
set seed 12345.
do repeat v = v1 to v10.
compute v=rv.uniform(1,10).
end repeat.
list.
descriptives all.



Jeff-2 wrote
> but also wanted to change *ALL* of the different seeds across multiple
> datasets that contained the same variables by simply changing a single
> “master-seed”.

If you re-run the code above with a different (master) seed value, you'll get another dataset with different values in v1-v10, but also different from the first dataset.  So like Rick, I don't understand the need to set additional seeds beyond the initial "master" seed.  If Jon explained the rationale somewhere, I missed it.  





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

--
Sent from: http://spssx-discussion.1045642.n5.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: Using a constant

Jon Peck
Some procedures draw from the same random number generator used in the rv functions, but I don't think any of them would reset the generator.  In fact, there would be no record of the orginal seed.  And note that compute statements are not actually executed until the next data pass, so they would not affect the current seed until then.  In addition, there is the issue of which generator - traditionall or Mersenne, is in effect.  SHOW RNG displays this.  Since this is a preference setting, the setting might not be evident in any particular syntax stream.

As for resetting the seed as in my previous post, I exposed the seed value through a macro definition, but if the seed need not be visible that way, the adjust function could just set the seed directly without the need for a macro and additional SET SEED (or SET MTINDEX) commands. Setting the seed at particular points in the syntax helps to modularize the syntax so that it is unaffected by changes elsewhere in the stream, which was the original goal.

begin program.
import spss

# change this single value as desired.
SEED_CONSTANT = 888.
def adjust(increment):
    spss.Submit("set seed %s." % (SEED_CONSTANT + increment))
end program.

begin program.
adjust(87654)
end program.
show seed.


On Tue, Feb 26, 2019 at 6:45 AM Jeff <[hidden email]> wrote:
You've got me curious so I ran a few tests. I'm unsure of the exact rules spss uses for resetting the seed, but apparently certain things cause the seed to revert back to a random number from the manually set one while other procedures don't.  The code below provides different results depending upon whether the descriptives output is run or left commented out in between the two computation of a and b. If the Desc a b line is not run, the show seed command produces 123456 both times. If it is run, it's altered for the second time.

It appears that as soon as I ask for output, the seed gets reset. I was doing that to test along the way, so I guess if I wasn't testing by asking for output, your version without Jon's complications would likely work just fine.




set seed 123456.
compute a=rv.uniform(1,10).
compute b=rv.uniform(1,10).
Show Seed.

 *  Desc a b .

compute a=rv.uniform(1,10).
compute b=rv.uniform(1,10).
Show Seed.
Desc a b.




-----Original Message-----
From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Bruce Weaver
Sent: Tuesday, 26 February 2019 10:31 PM
To: [hidden email]
Subject: Re: Using a constant

Jeff-2 wrote
> Yes. See my prior post. Jon figured out what I was trying to do even
> though my explanation wasn’t great and example code wasn’t anywhere
> close to being correct. I did need to change the seed for each
> variable within a particular dataset so these variables within the
> same dataset would contain different values,

If you try Rick's code, or the modified version of it below, you'll see that the variables v1 to v10 DO contain different values. 

data list free /z.
begin data
1 2 3 4 5
end data.
set seed 12345.
do repeat v = v1 to v10.
compute v=rv.uniform(1,10).
end repeat.
list.
descriptives all.



Jeff-2 wrote
> but also wanted to change *ALL* of the different seeds across multiple
> datasets that contained the same variables by simply changing a single
> “master-seed”.

If you re-run the code above with a different (master) seed value, you'll get another dataset with different values in v1-v10, but also different from the first dataset.  So like Rick, I don't understand the need to set additional seeds beyond the initial "master" seed.  If Jon explained the rationale somewhere, I missed it. 





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

--
Sent from: http://spssx-discussion.1045642.n5.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


--
Jon K Peck
[hidden email]

===================== 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: Using a constant

Jeff A

 

So how does one create a simple plain constant value in spss to use in some way?

 

E.g.,

Define X().

 

Compute Y = 8 + X.

 

Jeff

 

 

 

From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Jon Peck
Sent: Wednesday, 27 February 2019 12:31 AM
To: [hidden email]
Subject: Re: Using a constant

 

Some procedures draw from the same random number generator used in the rv functions, but I don't think any of them would reset the generator.  In fact, there would be no record of the orginal seed.  And note that compute statements are not actually executed until the next data pass, so they would not affect the current seed until then.  In addition, there is the issue of which generator - traditionall or Mersenne, is in effect.  SHOW RNG displays this.  Since this is a preference setting, the setting might not be evident in any particular syntax stream.

 

As for resetting the seed as in my previous post, I exposed the seed value through a macro definition, but if the seed need not be visible that way, the adjust function could just set the seed directly without the need for a macro and additional SET SEED (or SET MTINDEX) commands. Setting the seed at particular points in the syntax helps to modularize the syntax so that it is unaffected by changes elsewhere in the stream, which was the original goal.

 

begin program.

import spss

 

# change this single value as desired.

SEED_CONSTANT = 888.

def adjust(increment):

    spss.Submit("set seed %s." % (SEED_CONSTANT + increment))

end program.

 

begin program.

adjust(87654)

end program.

show seed.

 

 

On Tue, Feb 26, 2019 at 6:45 AM Jeff <[hidden email]> wrote:

You've got me curious so I ran a few tests. I'm unsure of the exact rules spss uses for resetting the seed, but apparently certain things cause the seed to revert back to a random number from the manually set one while other procedures don't.  The code below provides different results depending upon whether the descriptives output is run or left commented out in between the two computation of a and b. If the Desc a b line is not run, the show seed command produces 123456 both times. If it is run, it's altered for the second time.

It appears that as soon as I ask for output, the seed gets reset. I was doing that to test along the way, so I guess if I wasn't testing by asking for output, your version without Jon's complications would likely work just fine.




set seed 123456.
compute a=rv.uniform(1,10).
compute b=rv.uniform(1,10).
Show Seed.

 *  Desc a b .

compute a=rv.uniform(1,10).
compute b=rv.uniform(1,10).
Show Seed.
Desc a b.




-----Original Message-----
From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Bruce Weaver
Sent: Tuesday, 26 February 2019 10:31 PM
To: [hidden email]
Subject: Re: Using a constant

Jeff-2 wrote
> Yes. See my prior post. Jon figured out what I was trying to do even
> though my explanation wasn’t great and example code wasn’t anywhere
> close to being correct. I did need to change the seed for each
> variable within a particular dataset so these variables within the
> same dataset would contain different values,

If you try Rick's code, or the modified version of it below, you'll see that the variables v1 to v10 DO contain different values. 

data list free /z.
begin data
1 2 3 4 5
end data.
set seed 12345.
do repeat v = v1 to v10.
compute v=rv.uniform(1,10).
end repeat.
list.
descriptives all.



Jeff-2 wrote
> but also wanted to change *ALL* of the different seeds across multiple
> datasets that contained the same variables by simply changing a single
> “master-seed”.

If you re-run the code above with a different (master) seed value, you'll get another dataset with different values in v1-v10, but also different from the first dataset.  So like Rick, I don't understand the need to set additional seeds beyond the initial "master" seed.  If Jon explained the rationale somewhere, I missed it. 





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

--
Sent from: http://spssx-discussion.1045642.n5.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


 

--

Jon K Peck
[hidden email]

===================== 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: Using a constant

Jon Peck
A simple macro will do it.

define !myconstant()
  21 !enddefine.

compute z = !myconstant.

On Tue, Feb 26, 2019 at 3:59 PM Jeff <[hidden email]> wrote:

 

So how does one create a simple plain constant value in spss to use in some way?

 

E.g.,

Define X().

 

Compute Y = 8 + X.

 

Jeff

 

 

 

From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Jon Peck
Sent: Wednesday, 27 February 2019 12:31 AM
To: [hidden email]
Subject: Re: Using a constant

 

Some procedures draw from the same random number generator used in the rv functions, but I don't think any of them would reset the generator.  In fact, there would be no record of the orginal seed.  And note that compute statements are not actually executed until the next data pass, so they would not affect the current seed until then.  In addition, there is the issue of which generator - traditionall or Mersenne, is in effect.  SHOW RNG displays this.  Since this is a preference setting, the setting might not be evident in any particular syntax stream.

 

As for resetting the seed as in my previous post, I exposed the seed value through a macro definition, but if the seed need not be visible that way, the adjust function could just set the seed directly without the need for a macro and additional SET SEED (or SET MTINDEX) commands. Setting the seed at particular points in the syntax helps to modularize the syntax so that it is unaffected by changes elsewhere in the stream, which was the original goal.

 

begin program.

import spss

 

# change this single value as desired.

SEED_CONSTANT = 888.

def adjust(increment):

    spss.Submit("set seed %s." % (SEED_CONSTANT + increment))

end program.

 

begin program.

adjust(87654)

end program.

show seed.

 

 

On Tue, Feb 26, 2019 at 6:45 AM Jeff <[hidden email]> wrote:

You've got me curious so I ran a few tests. I'm unsure of the exact rules spss uses for resetting the seed, but apparently certain things cause the seed to revert back to a random number from the manually set one while other procedures don't.  The code below provides different results depending upon whether the descriptives output is run or left commented out in between the two computation of a and b. If the Desc a b line is not run, the show seed command produces 123456 both times. If it is run, it's altered for the second time.

It appears that as soon as I ask for output, the seed gets reset. I was doing that to test along the way, so I guess if I wasn't testing by asking for output, your version without Jon's complications would likely work just fine.




set seed 123456.
compute a=rv.uniform(1,10).
compute b=rv.uniform(1,10).
Show Seed.

 *  Desc a b .

compute a=rv.uniform(1,10).
compute b=rv.uniform(1,10).
Show Seed.
Desc a b.




-----Original Message-----
From: SPSSX(r) Discussion <[hidden email]> On Behalf Of Bruce Weaver
Sent: Tuesday, 26 February 2019 10:31 PM
To: [hidden email]
Subject: Re: Using a constant

Jeff-2 wrote
> Yes. See my prior post. Jon figured out what I was trying to do even
> though my explanation wasn’t great and example code wasn’t anywhere
> close to being correct. I did need to change the seed for each
> variable within a particular dataset so these variables within the
> same dataset would contain different values,

If you try Rick's code, or the modified version of it below, you'll see that the variables v1 to v10 DO contain different values. 

data list free /z.
begin data
1 2 3 4 5
end data.
set seed 12345.
do repeat v = v1 to v10.
compute v=rv.uniform(1,10).
end repeat.
list.
descriptives all.



Jeff-2 wrote
> but also wanted to change *ALL* of the different seeds across multiple
> datasets that contained the same variables by simply changing a single
> “master-seed”.

If you re-run the code above with a different (master) seed value, you'll get another dataset with different values in v1-v10, but also different from the first dataset.  So like Rick, I don't understand the need to set additional seeds beyond the initial "master" seed.  If Jon explained the rationale somewhere, I missed it. 





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

--
Sent from: http://spssx-discussion.1045642.n5.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


 

--

Jon K Peck
[hidden email]

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



--
Jon K Peck
[hidden email]

===================== 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: Using a constant

Art Kendall
In reply to this post by Jeff A
create an SPS file e.g., MyConstant.sps

with contents something like.
compute MyConstant = 20170227.

in the large syntax file
include c:\MyProject\MyConstant.sps.



-----
Art Kendall
Social Research Consultants
--
Sent from: http://spssx-discussion.1045642.n5.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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Using a constant

Jon Peck
The trouble is, MyConstant would then be a casewise variable where a scalar is wanted, so something like SET SEED MyConstant would not work.

On Wed, Feb 27, 2019 at 8:07 AM Art Kendall <[hidden email]> wrote:
create an SPS file e.g., MyConstant.sps

with contents something like.
compute MyConstant = 20170227.

in the large syntax file
include c:\MyProject\MyConstant.sps.



-----
Art Kendall
Social Research Consultants
--
Sent from: http://spssx-discussion.1045642.n5.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


--
Jon K Peck
[hidden email]

===================== 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: Using a constant

Art Kendall
I may not understand what is wanted.  My eSPSS (to steal David's term) is
that the OP wants to have a way to create a set of syntax that can be left
intact but still have a way to change the seed. I.e., use the old seed or a
new seed as desired without editing the big worked out set of syntax.


So, create an SPS file e.g., MySeed.sps
with contents something like.
set seed 20170227.

in the large syntax file
include 'c:\MyProject\MySeed.sps'.

It appears that there is some lack of clarity about what a seed is in a PRNG
--  Pseudorandom Number Generator.
Roughly
-- a seed is set by the user or from the internal clock or something
-- it is multiplied by a big constant in a formula
-- the low order bits are the generated pseudorandom number (PRN) and the
seed for the next call.

An identical series of calls starting with a given seed will produce the
same series of output pseudorandom numbers.
Different big constants have longer output series before they come back to
the original seed and start over with identical output series. At least in
the past SPSS used a constant that was shown to have a very long period
before it started over.
For most uses the PRNs are close enough to truly random.
For some applications the yielding an identical series of PRNs is a positive
thing.










-----
Art Kendall
Social Research Consultants
--
Sent from: http://spssx-discussion.1045642.n5.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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Using a constant

Bruce Weaver
Administrator
Good idea, Art.  However, I'm sure that when Jon reads this, he'll recommend
using INSERT rather than INCLUDE.  ;-)

INSERT 'C:\MyProject\MySeed.sps'.

https://www.ibm.com/support/knowledgecenter/en/SSLVMB_25.0.0/statistics_reference_project_ddita/spss/base/syn_insert.html

Cheers,
Bruce



Art Kendall wrote

> I may not understand what is wanted.  My eSPSS (to steal David's term) is
> that the OP wants to have a way to create a set of syntax that can be left
> intact but still have a way to change the seed. I.e., use the old seed or
> a
> new seed as desired without editing the big worked out set of syntax.
>
>
> So, create an SPS file e.g., MySeed.sps
> with contents something like.
> set seed 20170227.
>
> in the large syntax file
> include 'c:\MyProject\MySeed.sps'.
>
> It appears that there is some lack of clarity about what a seed is in a
> PRNG
> --  Pseudorandom Number Generator.
> Roughly
> -- a seed is set by the user or from the internal clock or something
> -- it is multiplied by a big constant in a formula
> -- the low order bits are the generated pseudorandom number (PRN) and the
> seed for the next call.
>
> An identical series of calls starting with a given seed will produce the
> same series of output pseudorandom numbers.
> Different big constants have longer output series before they come back to
> the original seed and start over with identical output series. At least in
> the past SPSS used a constant that was shown to have a very long period
> before it started over.
> For most uses the PRNs are close enough to truly random.
> For some applications the yielding an identical series of PRNs is a
> positive
> thing.
>
>
>
>
>
>
>
>
>
>
> -----
> Art Kendall
> Social Research Consultants
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

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

--
Sent from: http://spssx-discussion.1045642.n5.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
--
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: Using a constant

Jon Peck
Of course, Bruce.  But I think the original request was for a way to make only a single change to a syntax file, and using a separate file to hold the seed introduces an undesirable location dependency and complicates distributing the syntax.

And this reminds me that there is a somewhat esoteric extension command STATS FIND FILE available via the Extensions menu that can help with a bunch of related files.  You might use it by specifying a main syntax file, and it would create a file handle that could be used in INSERT commands in the main file to run related files in the same location without hard wiring the location.

Here is the beginning of its syntax help.
Define a file handle for the folder where the first instance of the specified file or wildcard is found.

STATS FIND FILE FILENAME = “file”*
FILEHANDLE = handle*
FOLDERLIST = “semicolon-separated list of folders”
ENVVARIABLE = “semi-colon-separated environment variable names”
SEARCHSUBFOLDERS = YES or NO**


On Thu, Feb 28, 2019 at 3:33 PM Bruce Weaver <[hidden email]> wrote:
Good idea, Art.  However, I'm sure that when Jon reads this, he'll recommend
using INSERT rather than INCLUDE.  ;-)

INSERT 'C:\MyProject\MySeed.sps'.

https://www.ibm.com/support/knowledgecenter/en/SSLVMB_25.0.0/statistics_reference_project_ddita/spss/base/syn_insert.html

Cheers,
Bruce



Art Kendall wrote
> I may not understand what is wanted.  My eSPSS (to steal David's term) is
> that the OP wants to have a way to create a set of syntax that can be left
> intact but still have a way to change the seed. I.e., use the old seed or
> a
> new seed as desired without editing the big worked out set of syntax.
>
>
> So, create an SPS file e.g., MySeed.sps
> with contents something like.
> set seed 20170227.
>
> in the large syntax file
> include 'c:\MyProject\MySeed.sps'.
>
> It appears that there is some lack of clarity about what a seed is in a
> PRNG
> --  Pseudorandom Number Generator.
> Roughly
> -- a seed is set by the user or from the internal clock or something
> -- it is multiplied by a big constant in a formula
> -- the low order bits are the generated pseudorandom number (PRN) and the
> seed for the next call.
>
> An identical series of calls starting with a given seed will produce the
> same series of output pseudorandom numbers.
> Different big constants have longer output series before they come back to
> the original seed and start over with identical output series. At least in
> the past SPSS used a constant that was shown to have a very long period
> before it started over.
> For most uses the PRNs are close enough to truly random.
> For some applications the yielding an identical series of PRNs is a
> positive
> thing.
>
>
>
>
>
>
>
>
>
>
> -----
> Art Kendall
> Social Research Consultants
> --
> Sent from: http://spssx-discussion.1045642.n5.nabble.com/
>
> =====================
> To manage your subscription to SPSSX-L, send a message to

> LISTSERV@.UGA

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

--
Sent from: http://spssx-discussion.1045642.n5.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: Using a constant

Art Kendall
INCLUDE vs INSERT is something I have to check help on every time I actually
use it.



-----
Art Kendall
Social Research Consultants
--
Sent from: http://spssx-discussion.1045642.n5.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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Using a constant

Jon Peck
There is a simple rule: always use INSERT.  It does everything INCLUDE does and has additional features.

On Fri, Mar 1, 2019 at 7:59 AM Art Kendall <[hidden email]> wrote:
INCLUDE vs INSERT is something I have to check help on every time I actually
use it.



-----
Art Kendall
Social Research Consultants
--
Sent from: http://spssx-discussion.1045642.n5.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


--
Jon K Peck
[hidden email]

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