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.

automatically numbering integer values

Postby paretto » Thu Oct 25, 2012 4:22 pm

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

Re: automatically numbering integer values

Postby TomDoan » Thu Oct 25, 2012 8:20 pm

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".
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm


Return to Help With Programming

Who is online

Users browsing this forum: No registered users and 0 guests