<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Generate sequence in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Generate-sequence/m-p/189942#M211051</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Peter.C,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my post above I have the two datasets first_dataset and second_dataset.&amp;nbsp; In the third datastep - which is the example - I set the two together and using the SAS autogenerated&amp;nbsp; _n_ assign a consecutive identifier, then split the output back out again to first_updated, second_updated.&amp;nbsp; Hence ending up with two datasets, one with id's 1-x (depending on obs), the second has id's x+1 - y (y is number of obs + x+ 1).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Feb 2014 10:47:59 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2014-02-28T10:47:59Z</dc:date>
    <item>
      <title>Generate sequence</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-sequence/m-p/189937#M211046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I have two tables contains . I want to generate sequence for each of these tables.If table-1 has 1- 20 sequence and table-2 must start with 21- x numbers(Records gets increases in this table based on count i need to increase the numbers.). How to generate. Can you help is generating sequence for table-2. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;venky&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Feb 2014 04:20:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-sequence/m-p/189937#M211046</guid>
      <dc:creator>pallis</dc:creator>
      <dc:date>2014-02-28T04:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: Generate sequence</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-sequence/m-p/189938#M211047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi it can be done by multiple ways couple are below:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: green; font-size: 10pt;"&gt;/*method 1*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: Consolas;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt; test1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt; sequence=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: Consolas;"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;to&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: Consolas;"&gt;20&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: Consolas;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: Consolas;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt; test2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt; _N_=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: Consolas;"&gt;0&lt;/STRONG&gt; &lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt; test1 nobs=nobs;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;sequence=nobs+&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: Consolas;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: Consolas;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: green; font-size: 10pt;"&gt;/*method2*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: Consolas;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt; test1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt; sequence=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: Consolas;"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;to&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: Consolas;"&gt;20&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: Consolas;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: Consolas;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: Consolas;"&gt;sql&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt; count(*) &lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;into&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;&amp;nbsp; :count &lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt; test1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: Consolas;"&gt;quit&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: Consolas;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt; test2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt; sequence=&amp;amp;count+&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: Consolas;"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;to&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: Consolas;"&gt;100&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: Consolas;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Feb 2014 07:20:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-sequence/m-p/189938#M211047</guid>
      <dc:creator>pradeepalankar</dc:creator>
      <dc:date>2014-02-28T07:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: Generate sequence</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-sequence/m-p/189939#M211048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One other way is to use in and output with _n_:&lt;/P&gt;&lt;P&gt;/* This is the test data */&lt;/P&gt;&lt;P&gt;data first_dataset (drop=i);&lt;BR /&gt;&amp;nbsp; attrib mytext format=$20.;&lt;BR /&gt;&amp;nbsp; do i=1 to 46;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mytext="AAANNDD";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;run;&lt;BR /&gt;data second_dataset (drop=i);&lt;BR /&gt;&amp;nbsp; attrib mytext format=$20.;&lt;BR /&gt;&amp;nbsp; do i=1 to 30;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mytext="GGHHYYSS";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;/* This is where the action happens */&lt;/P&gt;&lt;P&gt;data first_updated second_updated;&lt;BR /&gt;&amp;nbsp; set first_dataset (in=a) second_dataset (in=b);&lt;BR /&gt;&amp;nbsp; attrib id format=8.;&lt;BR /&gt;&amp;nbsp; id=_n_;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; if a then output first_updated;&lt;BR /&gt;&amp;nbsp; else output second_updated;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Feb 2014 09:28:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-sequence/m-p/189939#M211048</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-02-28T09:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: Generate sequence</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-sequence/m-p/189940#M211049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: Consolas;"&gt;Update : getting rid of proc sql: &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: Consolas;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt; test1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt; sequence=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: Consolas;"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;to&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: Consolas;"&gt;20&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt; symputx(&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: purple; font-size: 10pt;"&gt;'last_sequence'&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;,sequence);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: Consolas;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: Consolas;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt; test2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt; sequence=&amp;amp;last_sequence &lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;to&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10pt; background: white; font-family: Consolas;"&gt;100&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: blue; font-size: 10pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background: white; font-family: Consolas;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: Consolas; background: white; color: black; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Feb 2014 09:47:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-sequence/m-p/189940#M211049</guid>
      <dc:creator>pradeepalankar</dc:creator>
      <dc:date>2014-02-28T09:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: Generate sequence</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-sequence/m-p/189941#M211050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I do not understand the original question&lt;/P&gt;&lt;P&gt;Venky wrote&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P style="display: inline !important;"&gt;I have two tables &lt;/P&gt;
&lt;P style="display: inline !important;"&gt;&lt;/P&gt;
&lt;P style="display: inline !important;"&gt;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;In the solutions offered so far I see no reference to these tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Adding a variable to data normally involves writing a new table, but the question was&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P style="display: inline !important;"&gt;&amp;nbsp; I want to generate sequence for each of these tables.&lt;/P&gt;
&lt;P style="display: inline !important;"&gt;&lt;/P&gt;
&lt;P style="display: inline !important;"&gt;&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;Already SAS has a "sequence" that might be referred as "radix" for all base SAS datasets.&lt;/P&gt;&lt;P&gt;it is what&amp;nbsp; the POINT= option of a SET statement refers.&lt;/P&gt;&lt;P&gt;So, what is the purpose of the "sequence"?&lt;/P&gt;&lt;P&gt;Should the original tables be sorted before the "sequence" is added?&lt;/P&gt;&lt;P&gt;Is that reference to "1-20" dynamic based on 20 rows in the first table, or a 20-lag, or is it just an example to clarify how "sequence" is derived for/in the second table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think these "sequence" columns could (possibly should) be derived only in a view as the resultant data with sequences is used. The base SAS language supports this in two ways.&lt;/P&gt;&lt;P&gt;1&amp;nbsp; PROC SQL allows you to select a column filled with MONOTONIC() which is like a sequence. It is not documented but works (as long as all data is selected in a single process and not split across different threads - as we get a monotinic() sequence for each thread) e.g.&lt;/P&gt;&lt;P&gt;select d.*, ( 100+ monotonic() ) as sequence&amp;nbsp; from your.data D&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2 DATA STEP : allows an accumulator to be defined with a statement which looks like an assignment with no equals (=).&amp;nbsp;&amp;nbsp; E.g.&lt;/P&gt;&lt;P&gt;&amp;nbsp; Sequence+1&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both of these ways can be embedded within data VIEWs. A view stores the process until it is invoked in a PROC SQL FROM clause or a DATA STEP SET statement (or MERGE etc.)&lt;/P&gt;&lt;P&gt;An example DATA STEP&lt;/P&gt;&lt;P&gt;data view2seq/VIEW= view2seq ;&lt;/P&gt;&lt;P&gt;Retain sequence &amp;amp;initial_number ;&lt;/P&gt;&lt;P&gt;Set your.dataset2;&lt;/P&gt;&lt;P&gt;sequence + 1 ;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;Beware that "&amp;amp;initial_number" would be fixed when the view is compiled - before it is invoked. So that macro variable must be known at compile stage.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;peterC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Feb 2014 10:41:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-sequence/m-p/189941#M211050</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2014-02-28T10:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: Generate sequence</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-sequence/m-p/189942#M211051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Peter.C,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my post above I have the two datasets first_dataset and second_dataset.&amp;nbsp; In the third datastep - which is the example - I set the two together and using the SAS autogenerated&amp;nbsp; _n_ assign a consecutive identifier, then split the output back out again to first_updated, second_updated.&amp;nbsp; Hence ending up with two datasets, one with id's 1-x (depending on obs), the second has id's x+1 - y (y is number of obs + x+ 1).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Feb 2014 10:47:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-sequence/m-p/189942#M211051</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-02-28T10:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: Generate sequence</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Generate-sequence/m-p/189943#M211052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks for the replys I solved issue using retain &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Mar 2014 02:38:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Generate-sequence/m-p/189943#M211052</guid>
      <dc:creator>pallis</dc:creator>
      <dc:date>2014-03-14T02:38:32Z</dc:date>
    </item>
  </channel>
</rss>

