How to crate a Series of Integers

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.
Jules89
Posts: 140
Joined: Thu Jul 14, 2016 5:32 am

How to crate a Series of Integers

Unread post 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
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: How to crate a Series of Integers

Unread post 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)||)
Jules89
Posts: 140
Joined: Thu Jul 14, 2016 5:32 am

Re: How to crate a Series of Integers

Unread post 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
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: How to crate a Series of Integers

Unread post 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).
Jules89
Posts: 140
Joined: Thu Jul 14, 2016 5:32 am

Re: How to crate a Series of Integers

Unread post 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
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: How to crate a Series of Integers

Unread post 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.
Jules89
Posts: 140
Joined: Thu Jul 14, 2016 5:32 am

Re: How to crate a Series of Integers

Unread post by Jules89 »

Thanks you very much Tom.

Best jules
Post Reply