<?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: Equally distribute records to a list in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Equally-distribute-records-to-a-list/m-p/487321#M126971</link>
    <description>&lt;P&gt;It's not an automatic variable (like _N_ or _ERROR_), but one that comes into existence because it is named in the nobs= option.&lt;/P&gt;
&lt;P&gt;It is not included in outputs (it is implicitly dropped), and set once when the data step starts executing; if you re-set it, it loses its value:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set sashelp.class nobs=nobs;
if _n_ = 3 then nobs = 2;
put nobs=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 16 Aug 2018 09:11:42 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-08-16T09:11:42Z</dc:date>
    <item>
      <title>Equally distribute records to a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-distribute-records-to-a-list/m-p/487306#M126959</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data customer ;                                      
  input custid:$8;                   
  cards ;                                        
ABC123                                          
DEF456                                      
GHI789                                     
JKL101                                      
MNO112                                      
F000131                                     
G000415                                     
run ;                                            
                                                 
data staff ;                                     
  input staffname:$8;                     
  cards ;                                        
JOHN                                        
PAUL                                      
SARTRE                                
run ;

data want;
input custid:$8 staffname:$8;
 cards;
ABC123           JOHN                               
DEF456           PAUL                               
GHI789            SARTRE                       
JKL101            JOHN                        
MNO112          PAUL                        
F000131          SARTRE                      
G000415         JOHN
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any quick way to do so? Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 08:00:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-distribute-records-to-a-list/m-p/487306#M126959</guid>
      <dc:creator>t30</dc:creator>
      <dc:date>2018-08-16T08:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: Equally distribute records to a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-distribute-records-to-a-list/m-p/487307#M126960</link>
      <description>&lt;P&gt;One idea: use the point= option on the second dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data customer;
input custid :$8.;
cards;
ABC123
DEF456
GHI789
JKL101
MNO112
F000131
G000415
;
run;
                                                 
data staff;
input staffname :$8.;
cards;
JOHN
PAUL
SARTRE
;
run;

data want;
set customer;
if _n_ = 1 then inobs = 1;
set staff point=inobs nobs=nobs;
inobs + 1;
if inobs &amp;gt; nobs then inobs = 1;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Aug 2018 08:12:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-distribute-records-to-a-list/m-p/487307#M126960</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-16T08:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: Equally distribute records to a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-distribute-records-to-a-list/m-p/487309#M126961</link>
      <description>&lt;P&gt;PS do testruns of your code before you post it. As originally posted, your example datasets look quite funny:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data customer ;                                      
  input custid:$8;                   
  cards ;                                        
ABC123                                          
DEF456                                      
GHI789                                     
JKL101                                      
MNO112                                      
F000131                                     
G000415                                     
run ;                                            
                                                 
proc print data=customer;
run;

data staff ;                                     
  input staffname:$8;                     
  cards ;                                        
JOHN                                        
PAUL                                      
SARTRE                                
run ;

proc print data=staff;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;  Obs    custid

   1       D   
   2       J   
   3       F   
                 

 Obs    staffname

  1         P    
&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Aug 2018 08:10:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-distribute-records-to-a-list/m-p/487309#M126961</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-16T08:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: Equally distribute records to a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-distribute-records-to-a-list/m-p/487311#M126963</link>
      <description>That's awesome. Although I've to admit, it looks pretty cryptic ^^. I'll have a read further on this option.&lt;BR /&gt;&lt;BR /&gt;Thanks!</description>
      <pubDate>Thu, 16 Aug 2018 08:30:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-distribute-records-to-a-list/m-p/487311#M126963</guid>
      <dc:creator>t30</dc:creator>
      <dc:date>2018-08-16T08:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: Equally distribute records to a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-distribute-records-to-a-list/m-p/487312#M126964</link>
      <description>Thanks, will note this next time ^^</description>
      <pubDate>Thu, 16 Aug 2018 08:31:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-distribute-records-to-a-list/m-p/487312#M126964</guid>
      <dc:creator>t30</dc:creator>
      <dc:date>2018-08-16T08:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: Equally distribute records to a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-distribute-records-to-a-list/m-p/487319#M126969</link>
      <description>&lt;P&gt;Both the point= and the nobs= option define variables that are not included in any output datasets.&lt;/P&gt;
&lt;P&gt;The nobs= variable is set to the number of observations in the input dataset when the data step starts executing.&lt;/P&gt;
&lt;P&gt;The point= variable is used to read a selected observation from the input dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I set inobs in the first data step iteration (_n_ = 1) to 1, and increment it after reading (using &lt;FONT face="courier new,courier"&gt;inobs + 1;&lt;/FONT&gt; instead of &lt;FONT face="courier new,courier"&gt;inobs = inobs + 1;&lt;/FONT&gt; automatically retains it). If it passed the number of observations available, I reset it to 1.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 08:59:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-distribute-records-to-a-list/m-p/487319#M126969</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-16T08:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: Equally distribute records to a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-distribute-records-to-a-list/m-p/487320#M126970</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set staff point=inobs nobs=nobs;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What does the nobs=nobs do here?&lt;/P&gt;&lt;P&gt;is nobs (right) an automatic variable?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 09:03:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-distribute-records-to-a-list/m-p/487320#M126970</guid>
      <dc:creator>t30</dc:creator>
      <dc:date>2018-08-16T09:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: Equally distribute records to a list</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Equally-distribute-records-to-a-list/m-p/487321#M126971</link>
      <description>&lt;P&gt;It's not an automatic variable (like _N_ or _ERROR_), but one that comes into existence because it is named in the nobs= option.&lt;/P&gt;
&lt;P&gt;It is not included in outputs (it is implicitly dropped), and set once when the data step starts executing; if you re-set it, it loses its value:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set sashelp.class nobs=nobs;
if _n_ = 3 then nobs = 2;
put nobs=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Aug 2018 09:11:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Equally-distribute-records-to-a-list/m-p/487321#M126971</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-16T09:11:42Z</dc:date>
    </item>
  </channel>
</rss>

