<?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 How to draw n random samples from the original dataset in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-draw-n-random-samples-from-the-original-dataset/m-p/29064#M6805</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just as _null_ said.&lt;/P&gt;&lt;P&gt;How about:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;%do i=1 %to 4;
proc surveyselect data=list_stock method=srs n=4 out=sample&amp;amp;i noprint;
 run;
%end;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Jul 2011 07:30:48 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2011-07-12T07:30:48Z</dc:date>
    <item>
      <title>How to draw n random samples from the original dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-draw-n-random-samples-from-the-original-dataset/m-p/29062#M6803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I took a few very tedious steps to first create a few random variables, then sort the data based on the random variables. After that, I used the data set to select the first 200 responses. As I need to get 100 random samples to test a model, I would have to repeat this process for 100 times. Very poor idea and labor work. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am curious to learn if there is some code to automatically create 100 random samples from the orginal dataset. Something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let i=100;&lt;/P&gt;&lt;P&gt;data work.data01 work.data02 work.data03 ... work.data&amp;amp;i;&lt;BR /&gt;&amp;nbsp; set work.fulldata; /*fulldata has 1000 observations*/&lt;BR /&gt;&amp;nbsp; do j=1 to 100;&lt;BR /&gt;&amp;nbsp; ...output to different data sets with 200 observations;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;:smileyconfused:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jul 2011 19:31:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-draw-n-random-samples-from-the-original-dataset/m-p/29062#M6803</guid>
      <dc:creator>bncoxuk</dc:creator>
      <dc:date>2011-07-11T19:31:03Z</dc:date>
    </item>
    <item>
      <title>How to draw n random samples from the original dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-draw-n-random-samples-from-the-original-dataset/m-p/29063#M6804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use PROC SURVEYSELECT.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jul 2011 19:39:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-draw-n-random-samples-from-the-original-dataset/m-p/29063#M6804</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-07-11T19:39:36Z</dc:date>
    </item>
    <item>
      <title>How to draw n random samples from the original dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-draw-n-random-samples-from-the-original-dataset/m-p/29064#M6805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just as _null_ said.&lt;/P&gt;&lt;P&gt;How about:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;%do i=1 %to 4;
proc surveyselect data=list_stock method=srs n=4 out=sample&amp;amp;i noprint;
 run;
%end;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jul 2011 07:30:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-draw-n-random-samples-from-the-original-dataset/m-p/29064#M6805</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-07-12T07:30:48Z</dc:date>
    </item>
    <item>
      <title>How to draw n random samples from the original dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-draw-n-random-samples-from-the-original-dataset/m-p/29065#M6806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thanks for reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can proc surveyselect accommodate the flexibility that one part of the original data sample must be selected all the time, while the other party is used for drawing random samples. To put it simply, if there is a variable called ind. If ind=1, then all observations should be selected. If ind=0, then just select 100 observations (out of the origninal 500). How can I add this to the surveyselect procedure?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jul 2011 09:04:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-draw-n-random-samples-from-the-original-dataset/m-p/29065#M6806</guid>
      <dc:creator>bncoxuk</dc:creator>
      <dc:date>2011-07-12T09:04:52Z</dc:date>
    </item>
    <item>
      <title>How to draw n random samples from the original dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-draw-n-random-samples-from-the-original-dataset/m-p/29066#M6807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You want to do a stratified sample where IND is the strata.&amp;nbsp; The RATE or N parameters accept a list of rates or Ns to match the number of strata.&amp;nbsp; In the example IND=0 selects 4 obs and IND=1 selects all obs.&amp;nbsp; Or you can use RATE.&amp;nbsp; Be sure to use a difference well selected seed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The REP parameter creates,&amp;nbsp; in this example 4 independent samples, use REPLICATE in a BY statement instead of those %DOs.&amp;nbsp; Everything will be much faster and neatly contained in one data set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; sashelp.class(in=in1) sashelp.class;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp; ind = in1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;sort&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;=test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; ind;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;surveyselect&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;rep&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt; n&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;=(&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;4&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;,&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;19&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: green; font-family: 'Courier New'; background-color: white;"&gt;/*rate=(.4,1)*/&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;=test &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;out&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;=sample &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;seed&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;443754790&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;strata&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; ind;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;sort&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;=sample;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; replicate;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;print&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;=sample;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; replicate;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;id&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; replicate;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jul 2011 11:37:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-draw-n-random-samples-from-the-original-dataset/m-p/29066#M6807</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-07-12T11:37:47Z</dc:date>
    </item>
    <item>
      <title>How to draw n random samples from the original dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-draw-n-random-samples-from-the-original-dataset/m-p/29067#M6808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You also can split the origin dataset into two datasets ,one contains ind=1 and the other contains ind=0,&lt;/P&gt;&lt;P&gt;then &lt;/P&gt;&lt;P&gt;%do i=1 %to 4;&lt;/P&gt;&lt;P&gt;proc surveyselect data=list_stock method=srs n=4 out=sample&amp;amp;i noprint;&lt;/P&gt;&lt;P&gt; run;&lt;/P&gt;&lt;P&gt;data sample&amp;amp;i;&lt;/P&gt;&lt;P&gt; set sample&amp;amp;i ind_1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jul 2011 03:12:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-draw-n-random-samples-from-the-original-dataset/m-p/29067#M6808</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-07-15T03:12:05Z</dc:date>
    </item>
  </channel>
</rss>

