<?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 Shuffle the data rows available in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625904#M184545</link>
    <description>I have a data like&lt;BR /&gt;Data&lt;BR /&gt;Set&lt;BR /&gt;Plan&lt;BR /&gt;View&lt;BR /&gt;As per my requirement the data has to get shuffled in a random way like any thing, may be like&lt;BR /&gt;Plan&lt;BR /&gt;Set&lt;BR /&gt;Data&lt;BR /&gt;View</description>
    <pubDate>Wed, 19 Feb 2020 17:25:02 GMT</pubDate>
    <dc:creator>Rajeshganta</dc:creator>
    <dc:date>2020-02-19T17:25:02Z</dc:date>
    <item>
      <title>Shuffle the data rows available</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625904#M184545</link>
      <description>I have a data like&lt;BR /&gt;Data&lt;BR /&gt;Set&lt;BR /&gt;Plan&lt;BR /&gt;View&lt;BR /&gt;As per my requirement the data has to get shuffled in a random way like any thing, may be like&lt;BR /&gt;Plan&lt;BR /&gt;Set&lt;BR /&gt;Data&lt;BR /&gt;View</description>
      <pubDate>Wed, 19 Feb 2020 17:25:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625904#M184545</guid>
      <dc:creator>Rajeshganta</dc:creator>
      <dc:date>2020-02-19T17:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: Shuffle the data rows available</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625908#M184548</link>
      <description>&lt;P&gt;Assign a random number to each row, then sort by the random number.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 17:46:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625908#M184548</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-19T17:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: Shuffle the data rows available</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625919#M184549</link>
      <description>PROC SURVEYSELECT?</description>
      <pubDate>Wed, 19 Feb 2020 18:05:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625919#M184549</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-02-19T18:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: Shuffle the data rows available</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625923#M184550</link>
      <description>&lt;P&gt;I agree with the PROC SURVEYSELECT suggestion. Setting your SAMPRATE to 100 ensures you get all the data back in your "sample" but the order will be randomized. Even if you had groups of data such as a training set, test set, and validation set, you could use stratified sampling in SURVEYSELECT to keep this a pretty efficient approach.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 18:11:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625923#M184550</guid>
      <dc:creator>Duggins</dc:creator>
      <dc:date>2020-02-19T18:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: Shuffle the data rows available</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625924#M184551</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc surveyselect data=have out=shuffled
     rate=1 outorder=random;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See doc here:&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_surveyselect_syntax01.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=en#statug.surveyselect.selectoutrandom" target="_self"&gt;OUTORDER=RANDOM&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 18:32:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625924#M184551</guid>
      <dc:creator>Watts</dc:creator>
      <dc:date>2020-02-19T18:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: Shuffle the data rows available</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625929#M184552</link>
      <description>&lt;P&gt;It's simple with RAND group of functions like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; suggested&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Using SASHELP.CLASS*/
data want ;                           
  do _n_ = 1 to n ;                  
    p =   ceil (rand ("uniform") * n);         
    set sashelp.class point=p nobs=n ;
    output ;                          
  end ;                               
  stop ;                              
run ;  &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Feb 2020 18:20:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625929#M184552</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-19T18:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Shuffle the data rows available</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625934#M184553</link>
      <description>&lt;P&gt;Alternatively&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   create table want as
   select * from sashelp.class
   order by rand('uniform');
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Feb 2020 18:23:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625934#M184553</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-02-19T18:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: Shuffle the data rows available</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625935#M184554</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;It's simple with RAND group of functions like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; suggested&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Using SASHELP.CLASS*/
data want ;                           
  do _n_ = 1 to n ;                  
    p =   ceil (rand ("uniform") * n);         
    set sashelp.class point=p nobs=n ;
    output ;                          
  end ;                               
  stop ;                              
run ;  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;But data set WANT now has duplicates of some records, and other records are not present.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 18:23:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625935#M184554</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-19T18:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: Shuffle the data rows available</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625939#M184555</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/270201"&gt;@Watts&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc surveyselect data=have out=shuffled;
     rate=1 outorder=random;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See doc here:&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=statug&amp;amp;docsetTarget=statug_surveyselect_syntax01.htm&amp;amp;docsetVersion=15.1&amp;amp;locale=en#statug.surveyselect.selectoutrandom" target="_self"&gt;OUTORDER=RANDOM&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;There is an error here, there should be no semi-colon after OUT=SHUFFLED&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This solution fits my needs better than writing my own code, as I prefer to use SAS algorithms whenever possible (even in very simple cases), rather than writing my own, as I know SAS has taken the time to get it right and debugged it and tested it, and my own algorithms sometimes don't get it right.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 18:28:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625939#M184555</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-19T18:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: Shuffle the data rows available</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625942#M184556</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;Thanks for correcting my typo.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 18:31:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625942#M184556</guid>
      <dc:creator>Watts</dc:creator>
      <dc:date>2020-02-19T18:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: Shuffle the data rows available</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625965#M184564</link>
      <description>&lt;P&gt;Sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; Sorry, I overlooked the possibility of recurrence of the same random number. Good catch. But now, this tweak works, albeit boring&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want ;                                                                                                                                                                                                                                             
  array t [19] _temporary_ (1:19)  ;                                                                                                                                                                                                                   
  do until(_n=n) ;                                                                                                                    
    _n_ = ceil(rand ("uniform")*n);  
	if t(_n_)=. then continue;
    p = t(_n_);  
    set sashelp.class point=p nobs=n ;     
    _n+1;    
    output ;   
    t(_n_)=.; 
  end ;                                                                                                                                 
  stop ;   
  drop _:; 
run ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Feb 2020 19:57:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625965#M184564</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-19T19:57:22Z</dc:date>
    </item>
    <item>
      <title>Re: Shuffle the data rows available</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625968#M184567</link>
      <description>&lt;P&gt;May I ask why you go to such a complicated logic rather than the much simpler (and easier to understand) logic I originally stated; or the SQL solution above from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    z=rand('uniform');
run;
proc sort data=want;
    by z;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Feb 2020 20:01:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625968#M184567</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-19T20:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: Shuffle the data rows available</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625969#M184568</link>
      <description>&lt;P&gt;"&lt;STRONG&gt;why you go to such a complicated logic rather"-&amp;nbsp; &lt;/STRONG&gt;my dumb brain fails a lot of time. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;May I ask w&lt;STRONG&gt;hy you go to such a complicated logic rather&lt;/STRONG&gt; than the much simpler (and easier to understand) logic I originally stated; or the SQL solution above from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    z=rand('uniform');
run;
proc sort data=want;
    by z;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2020 20:03:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Shuffle-the-data-rows-available/m-p/625969#M184568</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-19T20:03:09Z</dc:date>
    </item>
  </channel>
</rss>

