Ask Your Question

# Revision history [back]

This can be accomplished in a number of ways.

1) Use of the Expanded Form of the SAMPLE command to select only the ranges (months) needed.

e.g. to select each August, assuming the series begins with February

sample 7 7 19 19 31 31 43 43 55 55


and so on for as many observations as you need.

2) Via a SKIPIF command

Read monthly observations along with an index from a free format text file, skip all but the 8th month indicated by the index then graph the variable.

read (testdata.txt) index variable
skipif(index.ne.8)
graph variable


2) Via a SKIPIF command using an index generated

Read monthly observations from a free format text file, create a month index and skip the 8th month index then graph. Note that TIME(1) adds 1 to the time index starting at 1 and MOD(12,12) = 0 so replace all the 0's with 12

read (testdata.txt) counter variable
genr monthind = mod(time(1), 12)
if(monthind.eq.0) monthind = 12
skipif(monthind.ne.8)
graph variable


This can be accomplished in a number of ways.

1) Use of the Expanded Form of the SAMPLE command to select only the ranges (months) needed.

e.g. to select each August, assuming the series begins with February

sample 7 7 19 19 31 31 43 43 55 55


and so on for as many observations as you need.

2) Via a SKIPIF commandcommand using a supplied month index

Read monthly observations along with an a month index from a free format text file, skip all but the 8th month indicated by the index then index, produce summary statistics for the subset and finally graph the variable.

read (testdata.txt) index month variable
skipif(index.ne.8)
skipif(month.ne.8)
stat variable
graph variable


2) 3) Via a SKIPIF command using an index generatedwe generate

Read monthly observations from a free format text file, create a month index, skip all but the 8th month indicated by the index, produce summary statistics for the subset and finally graph the variable formatting the x axis to show the month counter.

* Assuming we have monthly observations stored in a free format text file
* where the 1st observation is a February. Counter is from 1...N.
read (testdata1.txt) variable

* Generate month index and skip the 8th month noting the data starts from February
*   TIME(1) creates an index then graph. Note that TIME(1) adds by adding 1 to the time index starting at 1 and each value.
*   MOD(12,12) = 0 so replace all the 0's 0s with 12
genr month_ind=mod(time(1),12)
if(month_ind.eq.0) month_ind = 12

* Create a time index for the graph axis and adjust for start of February
time 2007 12 months
genr month = lag(months,-1)

* Skip any observations we do not want to use in estimation or graphing
set nowarnskip
skipif(month_ind.ne.8)

* Check basic statistics of the variable for just the 8th month
stat variable

* Draw a Graph
*  Use the TIMEFMT and AXISFMT commands to customise the X axis
*  Plot against the corrected month index
timefmt %Y.%m
axisfmt %m/%Y
graph variable month / timefmt axisfmt line


The output from this is:

read (testdata.txt) counter variable
genr monthind = mod(time(1), 12)
if(monthind.eq.0) monthind = 12
skipif(monthind.ne.8)
graph  |_stat variable
NAME        N    MEAN        ST. DEV      VARIANCE     MINIMUM      MAXIMUM
VARIABLE      4  0.16307E+08 0.15739E+08 0.24772E+15  0.11308E+06  0.36045E+08


The graph produced was: The data file used in this was: testdata1.txt

This can be accomplished in a number of ways.

1) Use of the Expanded Form of the SAMPLE command to select only the ranges (months) needed.

e.g. to select each August, assuming the series begins with February

sample 7 7 19 19 31 31 43 43 55 55


and so on for as many observations as you need.

2) Via a SKIPIF command using a supplied month index

Read monthly observations along with a month index from a free format text file, skip all but the 8th month indicated by the index, produce summary statistics for the subset and finally graph the variable.

read (testdata.txt) month variable
skipif(month.ne.8)
stat variable
graph variable


3) Via a SKIPIF command using an index we generate

Read monthly observations from a free format text file, create a month index, skip all but the 8th month indicated by the index, produce summary statistics for the subset and finally graph the variable formatting the x axis to show the month counter.

* Assuming we have monthly observations stored in a free format text file
* where the 1st observation is a February. Counter is from 1...N.
read (testdata1.txt) variable

* Generate month index noting the data starts from February
*   TIME(1) creates an index by adding 1 to each value.
*   MOD(12,12) = 0 so replace all 0s with 12
genr month_ind=mod(time(1),12)
if(month_ind.eq.0) month_ind = 12

* Create a time index for the graph axis and adjust for start of February
time 2007 12 months
genr month = lag(months,-1)

* Skip any observations we do not want to use in estimation or graphing
set nowarnskip
skipif(month_ind.ne.8)

* Check basic statistics of the variable for just the 8th month
stat variable

* Draw a Graph
*  Use the TIMEFMT and AXISFMT commands to customise the X axis
*  Plot against the corrected month index
timefmt %Y.%m
axisfmt %m/%Y
graph variable month / timefmt axisfmt line


The output from this is:

 |_stat variable
NAME        N    MEAN        ST. DEV      VARIANCE     MINIMUM      MAXIMUM
VARIABLE      4  0.16307E+08 0.15739E+08 0.24772E+15  0.11308E+06  0.36045E+08


The graph produced was:  The data file used in this was: testdata1.txt