Difference between revisions of "Sequence"

m
Line 25: Line 25:
 
''new to [[What's new in Analytica 4.2?|Analytica 4.2]]''
 
''new to [[What's new in Analytica 4.2?|Analytica 4.2]]''
  
You can use [[Sequence]] to generate a sequence of dates between a given start and stop date, in increments such as months and years, but specifying the optional «dateUnit» parameter.  Possible date units include: "Y" (years), "Q" (quarters), "M" (months), "WD" (weekdays), "D" (days), "h" (hours), "m" (minutes), "s" (seconds).
+
You can use [[Sequence]] to generate a sequence of dates between a given start and stop date, in increments such as months and years, by specifying the optional «dateUnit» parameter.  Possible date units include: "Y" (years), "Q" (quarters), "M" (months), "WD" (weekdays), "D" (days), "h" (hours), "m" (minutes), "s" (seconds).
  
 
  [[Sequence]]( [[MakeDate]](2009,1,1), [[MakeDate]](2010,12,31), 4, dateUnit:"M" ) →
 
  [[Sequence]]( [[MakeDate]](2009,1,1), [[MakeDate]](2010,12,31), 4, dateUnit:"M" ) →
 
   [ 1-Jan-2009, 1-May-2009, 1-Sep-2009, 1-Jan-2010, 1-May-2010, 1-Sep-2010 ]
 
   [ 1-Jan-2009, 1-May-2009, 1-Sep-2009, 1-Jan-2010, 1-May-2010, 1-Sep-2010 ]

Revision as of 00:23, 21 September 2009


Sequence( Start, End, step )

Creates a list of numbers increasing or decreasing from Start to End by increments (or decrements) of Stepsize. Stepsize is optional and must be a positive number; if it is omitted, Analytica uses increments of 1. Start, End and Stepsize must be deterministic scalar numbers, not arrays.

Declaration

Examples

Strict sequences

Sequence expects the «step» to be positive (or omitted, in which case a step of 1 is assumed). A decreasing sequence is obtained by specifying a «start» less than «end». As a result of this convention, a sequence will always have at least one element.

(new to Analytica 4.2) There are cases where a strict sequence is desired, such that the sequence proceeds from «start» in increments of «step», according to the sign of «step». When «step» proceeds in the direction away from «end», then a zero-length sequence results. For example, in a For..Do loop, you may want zero iterations when «end» is less than «start». A strict sequence is obtained by specifying the optional parameter «strict» as true, e.g.

Sequence(x1,x2,strict:true)

When «strict» is specified as true, the «step» may be negative, and must be negative to obtain a decreasing sequence.

Date Sequences

new to Analytica 4.2

You can use Sequence to generate a sequence of dates between a given start and stop date, in increments such as months and years, by specifying the optional «dateUnit» parameter. Possible date units include: "Y" (years), "Q" (quarters), "M" (months), "WD" (weekdays), "D" (days), "h" (hours), "m" (minutes), "s" (seconds).

Sequence( MakeDate(2009,1,1), MakeDate(2010,12,31), 4, dateUnit:"M" ) →
  [ 1-Jan-2009, 1-May-2009, 1-Sep-2009, 1-Jan-2010, 1-May-2010, 1-Sep-2010 ]
Comments


You are not allowed to post comments.