automatically numbering integer values

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.
paretto
Posts: 13
Joined: Tue Mar 30, 2010 11:02 am

automatically numbering integer values

Unread post by paretto »

Deat Tom,

thanks a lot for the help last time. Now I search for a way to automatically attach a number to the name of an integer.

I have the following procedure, where I want to compute the mean for different periods and store this mean in integer a.
To prevent that a is overwritten within the loop I want to number integer "a" by the value of i.
But some how I cant find the value a1, a3 ...
Where is the error?


dofor i = 1 3 6 12 24
stats claw12tayuk firstob+range+length lastob-i
comp a = %mean
comp a +(i) = a
end dofor

Is there something like a series window for integers, where I can see all integers defined in the program?

Thanks a lot
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: automatically numbering integer values

Unread post by TomDoan »

paretto wrote:Deat Tom,

thanks a lot for the help last time. Now I search for a way to automatically attach a number to the name of an integer.

I have the following procedure, where I want to compute the mean for different periods and store this mean in integer a.
To prevent that a is overwritten within the loop I want to number integer "a" by the value of i.
But some how I cant find the value a1, a3 ...
Where is the error?


dofor i = 1 3 6 12 24
stats claw12tayuk firstob+range+length lastob-i
comp a = %mean
comp a +(i) = a
end dofor
That won't work. The only things that can be created with created variable names are series. I'm not sure what you want to do with them, but this might work better:

Code: Select all

compute [vect[int]] ends=||1,3,6,12,24||
dec vect a(%size(ends))
do i=1,%size(ends)
   stats claw12tayuk firstob+range+length lastob-ends(i)
   compute a(i)=%mean
end do i
A will then have the five values, and ENDS will have the corresponding slots.
paretto wrote: Is there something like a series window for integers, where I can see all integers defined in the program?
The closest thing to this is the View--User Variables operation. Pick the "Scalars".
Post Reply