<?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: subsetting random observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/subsetting-random-observations/m-p/38351#M7683</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;San:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you asking for 1.5% randomly selected from the entire data set?&amp;nbsp; Or do you want 1.5% of the subset that meets a given condition (you said "subset a random sample with a condition").&amp;nbsp; If it's the latter, then your question hasn't been answered yet. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 Aug 2012 12:47:50 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2012-08-14T12:47:50Z</dc:date>
    <item>
      <title>subsetting random observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/subsetting-random-observations/m-p/38347#M7679</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I have a data set in which i want to subset a sample with a condition. In the subset I want to pull out 1.5 % of random observations of a variable and take the average of it. &lt;BR /&gt;
&lt;BR /&gt;
I could do the first part of this task to pull the subset with a condition (using WHERE clause).&lt;BR /&gt;
&lt;BR /&gt;
I'm trying to figure out how I can pull 1.5 % of random observations of the variable.&lt;BR /&gt;
&lt;BR /&gt;
After that, I think I can use Avg function to get a mean of it.&lt;BR /&gt;
&lt;BR /&gt;
Appreciate you help!</description>
      <pubDate>Tue, 12 Aug 2008 06:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/subsetting-random-observations/m-p/38347#M7679</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-08-12T06:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: subsetting random observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/subsetting-random-observations/m-p/38348#M7680</link>
      <description>Hi.&lt;BR /&gt;
Check out the Surveyselect procedure if you have licence for SAS/STAT.&lt;BR /&gt;
If not, one usual way is to code :&lt;BR /&gt;
1) a data step that creates a random variable (using the RANUNI or RAND functions)&lt;BR /&gt;
2) sort the new dataset by this random variable&lt;BR /&gt;
3) keep only the x first observations of the sorted dataset.&lt;BR /&gt;
This last way of doing is just like shuffling cards.&lt;BR /&gt;
&lt;BR /&gt;
Olivier</description>
      <pubDate>Tue, 12 Aug 2008 06:55:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/subsetting-random-observations/m-p/38348#M7680</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2008-08-12T06:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: subsetting random observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/subsetting-random-observations/m-p/38349#M7681</link>
      <description>You can also do a subsetting if in the first datastep (on the new "ranuni"-variable). Then there is no need to sort and read the data a third time.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Linus</description>
      <pubDate>Tue, 12 Aug 2008 07:28:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/subsetting-random-observations/m-p/38349#M7681</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2008-08-12T07:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: subsetting random observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/subsetting-random-observations/m-p/38350#M7682</link>
      <description>The code below (second data step) is almost what SAS provides in the training for the SAS certification.&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick&lt;BR /&gt;
&lt;BR /&gt;
data work.rsubset;&lt;BR /&gt;
  set &lt;YOUR ds=""&gt; (where=(&lt;YOUR condition=""&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data work.rsubset(drop=obsleft sampsize); &lt;BR /&gt;
/*  sampsize=10; */&lt;BR /&gt;
  sampsize=ceil(totobs*0.015);&lt;BR /&gt;
  obsleft=totobs; &lt;BR /&gt;
  do while(sampsize&amp;gt;0); &lt;BR /&gt;
     pickit+1; &lt;BR /&gt;
     if ranuni(0)&lt;SAMPSIZE&gt;
        set sasuser.revenue point=pickit &lt;BR /&gt;
            nobs=totobs; &lt;BR /&gt;
        output; &lt;BR /&gt;
        sampsize=sampsize-1; &lt;BR /&gt;
     end; &lt;BR /&gt;
     obsleft=obsleft-1; &lt;BR /&gt;
  end; &lt;BR /&gt;
  stop; &lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: Patrick

Message was edited by: Patrick&lt;/SAMPSIZE&gt;&lt;/YOUR&gt;&lt;/YOUR&gt;</description>
      <pubDate>Tue, 12 Aug 2008 10:39:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/subsetting-random-observations/m-p/38350#M7682</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2008-08-12T10:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: subsetting random observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/subsetting-random-observations/m-p/38351#M7683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;San:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you asking for 1.5% randomly selected from the entire data set?&amp;nbsp; Or do you want 1.5% of the subset that meets a given condition (you said "subset a random sample with a condition").&amp;nbsp; If it's the latter, then your question hasn't been answered yet. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Aug 2012 12:47:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/subsetting-random-observations/m-p/38351#M7683</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2012-08-14T12:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: subsetting random observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/subsetting-random-observations/m-p/38352#M7684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We should also ask whether the subset is selected with or without replacement.&amp;nbsp; For small subsets of a large data set it probably does not matter a lot, but....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Aug 2012 18:41:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/subsetting-random-observations/m-p/38352#M7684</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2012-08-14T18:41:35Z</dc:date>
    </item>
  </channel>
</rss>

