SHAZAM Questions and Answers (Q&A) - RSS feedhttp://community.econometrics.com/questions/SHAZAM Econometrics, Statistics and Analytics Communityen<font color="white">Copyright <b>SHAZAM Analytics, 2018</b></font>Fri, 13 Jul 2012 07:16:02 +0000Organizing and analyzing selected seasons in time serieshttp://community.econometrics.com/question/235/organizing-and-analyzing-selected-seasons-in-time-series/**Hi all**,
**Background:** Let's say you want to analyze seasonal time series data - for example monthly data. The data are stored in one column - first observation is the past. Let's say you want to look closer on how one specific month has developed over time - for example August. Assume that the time series start in February (the first observation). **Question**: How can Shazam (11.0.9) select one specific month (in this case August) for all years?
Best regards,P.Wed, 11 Jul 2012 06:04:06 +0000http://community.econometrics.com/question/235/organizing-and-analyzing-selected-seasons-in-time-series/Answer by SHAZAMHelp for <p><strong>Hi all</strong>,</p>
<p><strong>Background:</strong> Let's say you want to analyze seasonal time series data - for example monthly data. The data are stored in one column - first observation is the past. Let's say you want to look closer on how one specific month has developed over time - for example August. Assume that the time series start in February (the first observation). <strong>Question</strong>: How can Shazam (11.0.9) select one specific month (in this case August) for all years?</p>
<p>Best regards,P.</p>
http://community.econometrics.com/question/235/organizing-and-analyzing-selected-seasons-in-time-series/?answer=327#post-id-327This 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:
![Graph](http://community.econometrics.com/upfiles/13422124217175463.png)
The data file used in this was:
[testdata1.txt](http://community.econometrics.com/upfiles/13422127027632406.txt)Fri, 13 Jul 2012 07:16:02 +0000http://community.econometrics.com/question/235/organizing-and-analyzing-selected-seasons-in-time-series/?answer=327#post-id-327