{smcl} {* 27mar2006}{...} {hline} help for {cmd:sqegen}{right:(SJ6-4: st0111)} {hline} {title:Extensions to generate (for sequence data)} {p 8 17 2}{cmd:egen} [{it:type}] {it:newvar} {cmd:=} {it:sqfcn}{cmd:()} {ifin} [{cmd:,} {it:options}] {title:Description} {pstd} {helpb egen} creates {it:newvar} of the optionally specified storage type equal to {it:sqfcn}{cmd:()}. Unlike standard {cmd:egen} syntax, argument of {it:sqfcn}{cmd:()} is generally left empty. {title:Functions} {phang} {cmd:sqelemcount()} [{cmd:,} {opt e:lement(#)} {cmd:gapinclude}] generates a variable holding the number of different elements in each sequence. If {cmd:gapinclude} is specified, variables get defined even for sequences containing gaps. Missing values are generally counted as an element of their own. You might consider using {cmd:sqset} with option {cmd:trim} to get rid of superfluous missings. {phang} {cmd:sqepicount()} [{cmd:,} {opt e:lement(#)} {cmd:gapinclude}] separates a sequence into sections of equal elements (called "episodes"), and generates a variable holding the number of episodes for each sequence. With option {cmd:element()} only the number of episodes of the specified element is generated. If {cmd:gapinclude} is specified, variables get defined even for sequences containing gaps. Episodes with missing values are generally counted as an element of their own. You might consider using {cmd:sqset} with option {cmd:trim} to get rid of superfluous missings. {phang} {cmd:sqlength()} [{cmd:,} {opt e:lement(#)} {cmd:gapinclude}] generates a variable holding the length -- the number of positions -- of each observed sequence. With option {cmd:element()}, the length of all episodes of the specified element is generated. If {cmd:gapinclude} is specified, variables get defined even for sequences containing gaps. Episodes with missing values adds to the length of the sequences. You might consider using {cmd:sqset} with option {cmd:trim} to get rid of superfluous missings. {phang} {cmd:sqgapcount()} generates a variable holding the number of gap episodes in each sequence. Only gaps within a sequence is counted as gap (see {help sq##3:sq}). You might consider using {cmd:sqset} with option {cmd:trim} to get rid of "gaps" at the beginning or the end of sequences. {phang} {cmd:sqgaplength()} generates a variable holding the overall length of gap episodes in each sequence. Only gaps within a sequence is counted as gap (see {help sq##3:sq}). You might consider using {cmd:sqset} with option {cmd:trim} to get rid of "gaps" at the beginning or the end of sequences. {title:Author} {pstd}Ulrich Kohler, WZB, kohler@wz-berlin.de{p_end} {title:Examples} {phang}{cmd:. egen length = sqlength()} {phang}{cmd:. egen length1 = sqlength(), element(1) gapinclude} {phang}{cmd:. egen elemnum = sqelemcount()} {phang}{cmd:. egen epinum = sqepicount()} {title:Also see} {psee}Manual: {bf:[D] egen} {psee}Online: {helpb egenmore} (if installed), {helpb sq}, {helpb sqdemo}, {helpb sqset}, {helpb sqdes}, {helpb sqegen}, {helpb sqstat}, {helpb sqindexplot}, {helpb sqparcoord}, {helpb sqom}, {helpb sqclusterdat}, {helpb sqclustermat} {p_end}