RATS 10.1
RATS 10.1

Instructions /

SCRATCH Instruction

Home Page

← Previous Next →

SCRATCH( options )  number start end base-1

Creates a block of consecutively-numbered scratch data series. This is largely obsolete as it's much easier to use a VECTOR[SERIES] or RECT[SERIES] instead.

Parameters

number

number of new series to create

start,end

range of entries to allocate to the new series. By default, the standard workspace range

base-1

(output) If you supply an INTEGER variable for this parameter, SCRATCH will set this variable equal to one less than the number assigned to the first series it creates. You can then use this variable in a variety of situations to access the series. You do not need to declare the variable ahead of time.

Options

MATRIX=RECTANGULAR matrix used for referencing elements [unused]

With MATRIX, you can access the entries of the series as a two dimensional array. Entry n of the mth scratch series is matrix(n,m).

Notes

SCRATCH is still supported to allow for legacy programs, but in any new programming you will probably find it much more convenient to use VECTOR or RECTANGULAR arrays of SERIES, which can be created with simple DECLARE instructions. For example:

 

declare vector[series] vs(10)

 

creates a VECTOR called VS, where each element of the array is a separate series.

 

For example, suppose we have N unit dummies and M regressors, and we need to create N x M dummy regressors—one for each combination of unit dummies and regressors. While this could be done with numbered series created using SCRATCH, it is much easier to construct, set, and use these dummy variables as a RECTANGULAR array of SERIES:

 

declare rectangular[series] dummies(nunits,nreg)

do i=1,nunits

   do j=1,nreg

      *

      * Set dummy to value of regressor when GROUPING variable

      * is equal to current unit number, zero otherwise:

      *

      set dummies(i,j) = (reglist(j)){0}*(grouping{0}==i)

      labels dummies(i,j)

      # %string(i)+%label([series] reglist(j))

   end do

end do

*

linreg depvar

# dummies

 

With SCRATCH, the setup isn’t that much more difficult (primarily requiring an additional counter variable):

 

compute dummycount = (nunits*nreg)

scratch dummycount / basenum

*

compute dummynum=basenum

dofor i = reglist

   do j=1,nunits

     compute dummynum=dummynum+1

         set dummynum = i{0}*(grouping{0}==j)

     labels dummynum

     # %string(j)+%label([series]i)

   end do j

end dofor

 

But referencing the list of series is certainly not as convenient:

 

linreg depvar

# basenum+1 to basenum+dummycount

 

This is especially true if you want to refer to a particular series—the RECT[SERIES] is much easier to keep track of than a block of numbered series:

 

print / dummies(3,1)


 


Copyright © 2025 Thomas A. Doan