Page 1 of 1

How to crate a Series of Integers

Posted: Mon Nov 14, 2016 9:59 am
by Jules89
Hello everybody,

I would like to create a series of integers for example a Series which contains the number 22 as an integer values for each entry.
My idea was:

declare SERIES[Integer] onem
set onem = 22

But then the following error occurs:
SX22. Expected Type SERIES[REAL], Got SERIES[INTEGER] Instead

How can I fix that problem?

Thank you for your help

Jules

Re: How to crate a Series of Integers

Posted: Mon Nov 14, 2016 10:14 am
by TomDoan
You have to use GSET for any SERIES type other than SERIES[REAL] (or SERIES[COMPLEX] which is done with CSET).

dec series[integer] s
gset s rstart rend = f=StateF(t),%ranbranch(||p*f(1),(1-p)*f(2)||)

Re: How to crate a Series of Integers

Posted: Mon Nov 14, 2016 10:38 am
by Jules89
Hey thank you very much!!

And I have one more question.
I want to transform a Real into an Integer. How do I do that? My code is:

compute lags = 22
display lags
fix(lags)

but then the following error occurs:

## OP3. This Instruction Does Not Have An Option P
>>>>fix(p)<<<

Thank you very much

Re: How to crate a Series of Integers

Posted: Mon Nov 14, 2016 11:21 am
by TomDoan
As you have that written, FIX(p) is a separate instruction. I'm not sure what you're trying to do in the code above, but

compute lags=fix(sqrt(500))

would make LAGS an integer that's the first value less than sqrt(500).

Re: How to crate a Series of Integers

Posted: Mon Nov 14, 2016 11:33 am
by Jules89
I create a real:
Computer lags = 22.000

And want to Transform it to an integer:
Compute lags1 = fix(lags)

Such that
Display lags1 -> 22 instead of 22.000 and the Programm should notice that lags1 is an integer

Is the Code right?

Thanks

Jules

Re: How to crate a Series of Integers

Posted: Mon Nov 14, 2016 11:37 am
by TomDoan
Yes. You just wanted (in the original question)

disp lag fix(lags)

with the fix(lags) on the same line, not a second line.

Re: How to crate a Series of Integers

Posted: Mon Nov 14, 2016 11:48 am
by Jules89
Thanks you very much Tom.

Best jules