<?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: Retain Array in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67592#M14642</link>
    <description>&amp;gt; &lt;BR /&gt;
&amp;gt; The problem is that I need to compare every record&lt;BR /&gt;
&amp;gt; with subsequent record.&lt;BR /&gt;
&lt;BR /&gt;
is this "half" a cartesian join ?&lt;BR /&gt;
 &lt;BR /&gt;
sounds like sql might offer simpler compare than a data step</description>
    <pubDate>Fri, 27 Aug 2010 13:03:36 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2010-08-27T13:03:36Z</dc:date>
    <item>
      <title>Retain Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67579#M14629</link>
      <description>Hi to all,&lt;BR /&gt;
I need to save two observation in two array. For example i have this data set (Information):&lt;BR /&gt;
&lt;BR /&gt;
    a1          a2          a3&lt;BR /&gt;
    1             2            3&lt;BR /&gt;
  1500      3400       780&lt;BR /&gt;
&lt;BR /&gt;
I try with this code:&lt;BR /&gt;
&lt;BR /&gt;
data example;&lt;BR /&gt;
&lt;BR /&gt;
       retain b1-b3 1;&lt;BR /&gt;
       set information (obs=1);&lt;BR /&gt;
       array b b1-b2 _Numeric_;&lt;BR /&gt;
&lt;BR /&gt;
       set information (   firstobs=2&lt;BR /&gt;
                                       obs=2);&lt;BR /&gt;
&lt;BR /&gt;
       array c _Numeric_;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
The SAS log shows that is all correct but the problem is that array b and array c have the same value :  1500      3400       780&lt;BR /&gt;
&lt;BR /&gt;
I would like to have : array b has this:        1             2            3&lt;BR /&gt;
                              array c has this:1500      3400       780&lt;BR /&gt;
&lt;BR /&gt;
Where is it the error?

Message was edited by: reone</description>
      <pubDate>Thu, 26 Aug 2010 21:07:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67579#M14629</guid>
      <dc:creator>reone</dc:creator>
      <dc:date>2010-08-26T21:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67580#M14630</link>
      <description>Hi:&lt;BR /&gt;
  This is a very good intro on how ARRAY processing works with SAS:&lt;BR /&gt;
&lt;A href="http://support.sas.com/rnd/papers/sgf07/arrays1780.pdf" target="_blank"&gt;http://support.sas.com/rnd/papers/sgf07/arrays1780.pdf&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Thu, 26 Aug 2010 21:10:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67580#M14630</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-08-26T21:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67581#M14631</link>
      <description>Thanks Cynthia,&lt;BR /&gt;
I have read the paper suggested from you, but I can't find the solution for my problem.&lt;BR /&gt;
Have you some other solution?&lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Thu, 26 Aug 2010 22:13:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67581#M14631</guid>
      <dc:creator>reone</dc:creator>
      <dc:date>2010-08-26T22:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67582#M14632</link>
      <description>What are you trying to accomplish?  Do you just want a SAS file that has the first record as variable names and the second as the data?&lt;BR /&gt;
&lt;BR /&gt;
Art</description>
      <pubDate>Fri, 27 Aug 2010 00:11:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67582#M14632</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2010-08-27T00:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67583#M14633</link>
      <description>I agree with Art's question about what exactly you are trying to accomplish.&lt;BR /&gt;
That said, I think your problem stems from not understanding that arrays point to a set variables, and that occurs at compile time.  They cannot be changed between steps like you apear to be trying.  Here is a simple solution to the problem as presented, but I suspect the example is so simplified that this might not work for you.&lt;BR /&gt;
&lt;BR /&gt;
data information;&lt;BR /&gt;
input a1 a2 a3;&lt;BR /&gt;
DATALINES; &lt;BR /&gt;
1 2 3&lt;BR /&gt;
1500 3400 780&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data example(drop = a1-a3);&lt;BR /&gt;
  array a a1-a3; &lt;BR /&gt;
  array b b1-b3; &lt;BR /&gt;
  array c c1-c3;&lt;BR /&gt;
  retain b c;&lt;BR /&gt;
  set information;&lt;BR /&gt;
  if _n_ = 1 then do;&lt;BR /&gt;
    do over a;&lt;BR /&gt;
      b = a;&lt;BR /&gt;
    end;&lt;BR /&gt;
  end;&lt;BR /&gt;
  if _n_ = 2 then do;&lt;BR /&gt;
    do over a;&lt;BR /&gt;
      c = a;&lt;BR /&gt;
    end;&lt;BR /&gt;
    output;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Curtis

I made a small but important wording change&lt;BR /&gt;
&lt;BR /&gt;
    &lt;BR /&gt;
Message was edited by: Curtis Mack</description>
      <pubDate>Fri, 27 Aug 2010 00:16:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67583#M14633</guid>
      <dc:creator>CurtisMack</dc:creator>
      <dc:date>2010-08-27T00:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67584#M14634</link>
      <description>Thanks for the answers!&lt;BR /&gt;
&lt;BR /&gt;
sorry if I was not clear, I repeat my problem:&lt;BR /&gt;
&lt;BR /&gt;
I Have this data set (TABLE)  INFORMATION:&lt;BR /&gt;
&lt;BR /&gt;
_N_    a1   a2   a3&lt;BR /&gt;
  1      1     2     3&lt;BR /&gt;
  2     12   14   15&lt;BR /&gt;
&lt;BR /&gt;
where _N_          : is number of observation&lt;BR /&gt;
         a1 a2 a3    : are the fields &lt;BR /&gt;
&lt;BR /&gt;
and in this Data Set I would like to have two array:&lt;BR /&gt;
array b:   1  2   3&lt;BR /&gt;
array c: 12 14 15&lt;BR /&gt;
&lt;BR /&gt;
Kurtis, I Have followed your solution (with DO OVER), but it not works the retain:&lt;BR /&gt;
&lt;BR /&gt;
data example;&lt;BR /&gt;
  array a a1-a3 _NUMERIC_;&lt;BR /&gt;
  array b b1-b3 _NUMERIC_;&lt;BR /&gt;
  array c c1-c3 _NUMERIC_;&lt;BR /&gt;
&lt;BR /&gt;
  retain b;&lt;BR /&gt;
  retain c;&lt;BR /&gt;
&lt;BR /&gt;
  set information;&lt;BR /&gt;
  if _N_ = 1 then do;&lt;BR /&gt;
     do over a ;&lt;BR /&gt;
       b=a;&lt;BR /&gt;
     end;&lt;BR /&gt;
 end;&lt;BR /&gt;
&lt;BR /&gt;
if _N_ = 2 then do;&lt;BR /&gt;
     do over a ;&lt;BR /&gt;
       c=a;&lt;BR /&gt;
     end;&lt;BR /&gt;
 end;&lt;BR /&gt;
&lt;BR /&gt;
do over b ;&lt;BR /&gt;
       put b;&lt;BR /&gt;
 end;&lt;BR /&gt;
&lt;BR /&gt;
do over c;&lt;BR /&gt;
  put c;&lt;BR /&gt;
end;&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The program running, but the retain it doesn't work. Moreover I can't access directly &lt;BR /&gt;
to variable b(2) or c(3);&lt;BR /&gt;
&lt;BR /&gt;
Have you an other solution?

Message was edited by: reone</description>
      <pubDate>Fri, 27 Aug 2010 07:53:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67584#M14634</guid>
      <dc:creator>reone</dc:creator>
      <dc:date>2010-08-27T07:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67585#M14635</link>
      <description>reone,&lt;BR /&gt;
&lt;BR /&gt;
I agree with Art and think it would be best to describe what you actually want to do. The bigger picture that is. Creating these arrays seems to be a small part of the actual problem only. While it might be possible to do what you want, it most certainly is not the best way to deal with the task at hand.&lt;BR /&gt;
&lt;BR /&gt;
Robert</description>
      <pubDate>Fri, 27 Aug 2010 08:49:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67585#M14635</guid>
      <dc:creator>Robert_Bardos</dc:creator>
      <dc:date>2010-08-27T08:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67586#M14636</link>
      <description>Hi Robert,&lt;BR /&gt;
&lt;BR /&gt;
The problem is that I need to compare every record with subsequent record.&lt;BR /&gt;
I have this data set:&lt;BR /&gt;
&lt;BR /&gt;
_N_  Mounth    Cod&lt;BR /&gt;
  1        1         8374&lt;BR /&gt;
  2        1         5647&lt;BR /&gt;
  3        2         8374&lt;BR /&gt;
  4        3         8375&lt;BR /&gt;
  5        3         654&lt;BR /&gt;
  6        3         328&lt;BR /&gt;
  ..&lt;BR /&gt;
167      12       8374&lt;BR /&gt;
&lt;BR /&gt;
I need to know for every COD, if this COD is in the subsequent months;&lt;BR /&gt;
I have thought to use the array;&lt;BR /&gt;
To do that, I use the proc transpose and in this new data set i have two observation; in the first I have the mounth and in the second i have the code.&lt;BR /&gt;
&lt;BR /&gt;
With these array I can compare the element with the successive elements;&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: reone

Message was edited by: reone</description>
      <pubDate>Fri, 27 Aug 2010 09:33:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67586#M14636</guid>
      <dc:creator>reone</dc:creator>
      <dc:date>2010-08-27T09:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67587#M14637</link>
      <description>One technique that I have seen reads the input dataset twice applying some kind of "firstobs based lookahead"&lt;BR /&gt;
[pre]&lt;BR /&gt;
 data _null_ ;                                                &lt;BR /&gt;
   set sashelp.class ;                                        &lt;BR /&gt;
   set sashelp.class (firstobs=2 keep=name sex                              &lt;BR /&gt;
                      rename=(name=next_name sex=next_sex)) ; &lt;BR /&gt;
   if sex=next_sex then put name 'and ' next_name 'same sex' ;&lt;BR /&gt;
   else put name 'and ' next_name 'different sex' ;           &lt;BR /&gt;
 run ;                                                        &lt;BR /&gt;
[/pre]&lt;BR /&gt;
The downside of this is that the datastep stops as soon as the last observation of the second set statement is read. A crude circumvention to this problem might be:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data _null_ ;                                                &lt;BR /&gt;
  set sashelp.class ;                                        &lt;BR /&gt;
  if not end_ds2 then                                        &lt;BR /&gt;
  set sashelp.class (firstobs=2 keep=name sex                              &lt;BR /&gt;
      rename=(name=next_name sex=next_sex)) end=end_ds2 ;    &lt;BR /&gt;
  if sex=next_sex then put name 'and ' next_name 'same sex' ;&lt;BR /&gt;
  else put name 'and ' next_name 'different sex' ;           &lt;BR /&gt;
run ;                                                        &lt;BR /&gt;
[/pre]&lt;BR /&gt;
Here you will have the values of the last observation from the second set statement carried forward by means of the retain mechanism. Bottom line: works but special care has to be taken for the last observation.&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;Important addition:&lt;/B&gt; forgot to add the keep= option to the second set statement. Failing to do so causes all other variables' values to be overwritten!&lt;BR /&gt;
&lt;BR /&gt;
    &lt;BR /&gt;
Message was edited by: Robert.Bardos</description>
      <pubDate>Fri, 27 Aug 2010 09:55:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67587#M14637</guid>
      <dc:creator>Robert_Bardos</dc:creator>
      <dc:date>2010-08-27T09:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67588#M14638</link>
      <description>&amp;gt; &lt;BR /&gt;
&amp;gt; The problem is that I need to compare every record&lt;BR /&gt;
&amp;gt; with subsequent record.&lt;BR /&gt;
 &lt;BR /&gt;
you need to have data from more than one observation available at a time&lt;BR /&gt;
 &lt;BR /&gt;
In these problem situations, I try hard to avoid making things too complicated, and sometimes using arrays makes things complicated. For example to compare every variable in the observation with every variable on the previous observation is impossible with an array when you have both numeric and character variables, and work-arounds with more arrays is completely unneccessary when lag() provides the information from the previous row (but needs columns named see call vnext() if that is an issue).&lt;BR /&gt;
To compare a set of variables on row N with the same set of variables on other rows could be done with something like[pre]data output_data_set ;&lt;BR /&gt;
  %let input_data_set = sashelp.class ; * or your.data_whatever ;&lt;BR /&gt;
  %let   list_columns = age height weight ; * list columns to be checked ;&lt;BR /&gt;
  %let       num_cols = 3 ; * enter correct number  or derive count from the list ;&lt;BR /&gt;
   if 0 then set &amp;amp;input_data_set ; * to load data attributes befre array statements;&lt;BR /&gt;
   array check(*) &amp;amp;list_columns ;* MUST have all the same data type ;&lt;BR /&gt;
   array x_ref(&amp;amp;num_cols) %*need to add $length for character columns; _temporary_ ;&lt;BR /&gt;
   primary_data_row = 19  ; * the row compare with other rows ;&lt;BR /&gt;
   if _N_ = 1 then do;&lt;BR /&gt;
      set &amp;amp;input_data_set point= primary_data_row ;&lt;BR /&gt;
      do _i_ = 1 to  &amp;amp;num_cols   ;&lt;BR /&gt;
         x_ref(_i_) = check(_i_) ;&lt;BR /&gt;
         * collecting the x_ref columns to check later ;&lt;BR /&gt;
      end ;&lt;BR /&gt;
   end ;&lt;BR /&gt;
   set &amp;amp;input_data_set ;&lt;BR /&gt;
   diffs = 0 ;&lt;BR /&gt;
   do _i_ = 1 to &amp;amp;num_cols ;&lt;BR /&gt;
       if check(_i_) ne x_ref(_i_) then do;&lt;BR /&gt;
          diffs +1 ;&lt;BR /&gt;
           * do anything appropriate to the _i_-th column of check array ;&lt;BR /&gt;
       end ;&lt;BR /&gt;
   end ;&lt;BR /&gt;
   if diffs then do; * whatever required when the compared columns have at least one difference;&lt;BR /&gt;
   end ;&lt;BR /&gt;
run ; [/pre]&lt;BR /&gt;
 &lt;BR /&gt;
So, that is a simple demo which works as I expect - remember  your problem may be different&lt;BR /&gt;
 &lt;BR /&gt;
luck&lt;BR /&gt;
peterC</description>
      <pubDate>Fri, 27 Aug 2010 12:23:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67588#M14638</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-08-27T12:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67589#M14639</link>
      <description>Thanks for the answer,&lt;BR /&gt;
I have tried your code and it works!&lt;BR /&gt;
&lt;BR /&gt;
but I have the problem that firstobs change and it isn't fix.&lt;BR /&gt;
firstobs has this value _N_ + 1&lt;BR /&gt;
&lt;BR /&gt;
I have modified  the firstobs in your code:&lt;BR /&gt;
&lt;BR /&gt;
data _null_ ;                                                &lt;BR /&gt;
  set sashelp.class ;&lt;BR /&gt;
  num = _N_+ 1;                                      &lt;BR /&gt;
  if not end_ds2 then                                        &lt;BR /&gt;
  set sashelp.class (firstobs=num                              &lt;BR /&gt;
      rename=(name=next_name sex=next_sex)) end=end_ds2 ;    &lt;BR /&gt;
  if sex=next_sex then put name 'and ' next_name 'same sex' ;&lt;BR /&gt;
  else put name 'and ' next_name 'different sex' ;           &lt;BR /&gt;
run ;   &lt;BR /&gt;
&lt;BR /&gt;
but it doesn't work!</description>
      <pubDate>Fri, 27 Aug 2010 12:46:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67589#M14639</guid>
      <dc:creator>reone</dc:creator>
      <dc:date>2010-08-27T12:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67590#M14640</link>
      <description>Did you see the keep= option that I added by modifying my original post? Look for "important addition" and compare the code.</description>
      <pubDate>Fri, 27 Aug 2010 12:59:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67590#M14640</guid>
      <dc:creator>Robert_Bardos</dc:creator>
      <dc:date>2010-08-27T12:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67591#M14641</link>
      <description>have you looked at documentation for firstobs= ?&lt;BR /&gt;
When you do (or re-read) you will find that unlike "POINT=" the  value for "FIRSTOBS=" must be provided as a constant (it is really quite logical when you think about it)&lt;BR /&gt;
It is pointless in this situation (pardon pun)&lt;BR /&gt;
Comparing "this" with "next" is just the same as "this" with "previous", apart from a matter of timing. It's not forecasting.&lt;BR /&gt;
Why not do it the easy way&lt;BR /&gt;
dif1 = ( this_col = lag( this_col) ) ;&lt;BR /&gt;
dif2 = ( col2 = lag( col2) ) ;&lt;BR /&gt;
 &lt;BR /&gt;
 provides a simple model</description>
      <pubDate>Fri, 27 Aug 2010 13:00:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67591#M14641</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-08-27T13:00:55Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67592#M14642</link>
      <description>&amp;gt; &lt;BR /&gt;
&amp;gt; The problem is that I need to compare every record&lt;BR /&gt;
&amp;gt; with subsequent record.&lt;BR /&gt;
&lt;BR /&gt;
is this "half" a cartesian join ?&lt;BR /&gt;
 &lt;BR /&gt;
sounds like sql might offer simpler compare than a data step</description>
      <pubDate>Fri, 27 Aug 2010 13:03:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67592#M14642</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-08-27T13:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67593#M14643</link>
      <description>Peter is right. &lt;BR /&gt;
&lt;BR /&gt;
reone,&lt;BR /&gt;
&lt;BR /&gt;
Do you want to compare the observations with all subsequent observations?&lt;BR /&gt;
Or do you want to compare each observation with the immediately following observation only? (That was how I understood your problem, the ongoing discussion however seems to prove me wrong).&lt;BR /&gt;
&lt;BR /&gt;
Thanks for clarifying&lt;BR /&gt;
Robert</description>
      <pubDate>Fri, 27 Aug 2010 13:13:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67593#M14643</guid>
      <dc:creator>Robert_Bardos</dc:creator>
      <dc:date>2010-08-27T13:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67594#M14644</link>
      <description>Sorry to all if I wasn't clear before,&lt;BR /&gt;
&lt;BR /&gt;
yes i need to compare the observations with ALL subsequent observations!&lt;BR /&gt;
&lt;BR /&gt;
reone.</description>
      <pubDate>Fri, 27 Aug 2010 13:25:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67594#M14644</guid>
      <dc:creator>reone</dc:creator>
      <dc:date>2010-08-27T13:25:34Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67595#M14645</link>
      <description>if it is &lt;B&gt;each&lt;/B&gt; obs with all subsequent, then data step is going to need more trouble (set with point)  than sql _probably_&lt;BR /&gt;
Contrast the management of arrays (remembering the probable need for two - one nums other chars) with sql using  select column name++ into :host_variable over all columns required for compare, to generate the select statement defining columns out of the sql compare. Even though sql doesn't have the equivalent of the _n_ in data steps, it is easy to generate for the sql join filter[pre]   where A_n_ &amp;gt; B_n_ [/pre]with datastep view like[pre]data a/view=a ;&lt;BR /&gt;
  A_n_ +1;&lt;BR /&gt;
  set &amp;amp;input_data_set ;&lt;BR /&gt;
run ;&lt;BR /&gt;
data b/view=b ;&lt;BR /&gt;
  B_n_ +1 ;&lt;BR /&gt;
  set &amp;amp;input_data_set ;&lt;BR /&gt;
run ; [/pre]Then code needs to be generated to create the required outcome. Perhaps it would be enough to generate something like[pre]  select  A_n_, B_n_,  (a.name = B.name ) as d_name [/pre]where I hope "name" and its prefixes A., B. and D_  are indicative enough. The ( compare) part is repeated for each variable name in &amp;amp;input_data_set so proc contents out= or dictionary.columns would be used to retrieve that list of names as "data".&lt;BR /&gt;
This is clearly creating a lot of output data, not just a lot of coding trouble. Before investing more time - are you sure this is productive? Would you like to explain how this is useful to you?&lt;BR /&gt;
 &lt;BR /&gt;
peterC</description>
      <pubDate>Fri, 27 Aug 2010 14:27:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67595#M14645</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-08-27T14:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67596#M14646</link>
      <description>Why don't you sort the data by cod and mounth, so the info is grouped by cod? Then you process the sorted dataset with a BY.&lt;BR /&gt;
&lt;BR /&gt;
Am I mssing something here?</description>
      <pubDate>Fri, 27 Aug 2010 14:49:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67596#M14646</guid>
      <dc:creator>FloydNevseta</dc:creator>
      <dc:date>2010-08-27T14:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67597#M14647</link>
      <description>Thanks, Peter.C&lt;BR /&gt;
I have followed your advice, about to compare each record with ALL record in SQL and it works fine. Yes, I need to use this solution for my program.&lt;BR /&gt;
&lt;BR /&gt;
Thanks &lt;BR /&gt;
reone.</description>
      <pubDate>Sun, 29 Aug 2010 18:10:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Array/m-p/67597#M14647</guid>
      <dc:creator>reone</dc:creator>
      <dc:date>2010-08-29T18:10:26Z</dc:date>
    </item>
  </channel>
</rss>

