<?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: How to create a random sample showing picked observation numbers? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-random-sample-showing-picked-observation-numbers/m-p/54581#M11579</link>
    <description>This is what the documentation says about the point option:&lt;BR /&gt;
&lt;BR /&gt;
"The POINT= variable is available anywhere in the DATA step, but it is not added to any new SAS data set"&lt;BR /&gt;
&lt;BR /&gt;
But nothing is stopping you from assigning another variable the same value, which will then end up in your output table:&lt;BR /&gt;
&lt;BR /&gt;
data work.revenue (drop = i samplesize);&lt;BR /&gt;
	samplesize = 10;&lt;BR /&gt;
	do i = 1 to samplesize;&lt;BR /&gt;
		pickit = ceil(ranuni(0) * totobs);&lt;BR /&gt;
		&lt;B&gt;pick = pickit;&lt;/B&gt;&lt;BR /&gt;
		set sashelp.class point = pickit nobs = totobs; &lt;BR /&gt;
		output;&lt;BR /&gt;
	end;&lt;BR /&gt;
	stop;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Linus</description>
    <pubDate>Wed, 15 Oct 2008 20:20:28 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2008-10-15T20:20:28Z</dc:date>
    <item>
      <title>How to create a random sample showing picked observation numbers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-random-sample-showing-picked-observation-numbers/m-p/54580#M11578</link>
      <description>I want to create a sample from the &lt;I&gt;sasuser.revenue&lt;/I&gt; dataset and insert it as a new dataset called &lt;I&gt;work.revenue&lt;/I&gt;. This is the code I am submitting:&lt;BR /&gt;
&lt;BR /&gt;
data work.revenue (drop = i samplesize);&lt;BR /&gt;
	samplesize = 10;&lt;BR /&gt;
	do i = 1 to samplesize;&lt;BR /&gt;
		pickit = ceil(ranuni(0) * totobs);&lt;BR /&gt;
		set sasuser.revenue point = pickit nobs = totobs; 		                output;&lt;BR /&gt;
	end;&lt;BR /&gt;
	stop;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
It is working perfectly fine.&lt;BR /&gt;
&lt;BR /&gt;
However, how can I have the variable called &lt;B&gt;pickit&lt;/B&gt; to be part of my final dataset? Although this is a random sampling, I want to know which observations were picked during the process.&lt;BR /&gt;
&lt;BR /&gt;
Thanks for the help</description>
      <pubDate>Wed, 15 Oct 2008 18:42:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-random-sample-showing-picked-observation-numbers/m-p/54580#M11578</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-15T18:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a random sample showing picked observation numbers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-random-sample-showing-picked-observation-numbers/m-p/54581#M11579</link>
      <description>This is what the documentation says about the point option:&lt;BR /&gt;
&lt;BR /&gt;
"The POINT= variable is available anywhere in the DATA step, but it is not added to any new SAS data set"&lt;BR /&gt;
&lt;BR /&gt;
But nothing is stopping you from assigning another variable the same value, which will then end up in your output table:&lt;BR /&gt;
&lt;BR /&gt;
data work.revenue (drop = i samplesize);&lt;BR /&gt;
	samplesize = 10;&lt;BR /&gt;
	do i = 1 to samplesize;&lt;BR /&gt;
		pickit = ceil(ranuni(0) * totobs);&lt;BR /&gt;
		&lt;B&gt;pick = pickit;&lt;/B&gt;&lt;BR /&gt;
		set sashelp.class point = pickit nobs = totobs; &lt;BR /&gt;
		output;&lt;BR /&gt;
	end;&lt;BR /&gt;
	stop;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Linus</description>
      <pubDate>Wed, 15 Oct 2008 20:20:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-random-sample-showing-picked-observation-numbers/m-p/54581#M11579</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2008-10-15T20:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a random sample showing picked observation numbers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-random-sample-showing-picked-observation-numbers/m-p/54582#M11580</link>
      <description>Excellent. Thank you.</description>
      <pubDate>Wed, 15 Oct 2008 20:30:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-random-sample-showing-picked-observation-numbers/m-p/54582#M11580</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-15T20:30:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a random sample showing picked observation numbers?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-random-sample-showing-picked-observation-numbers/m-p/54583#M11581</link>
      <description>Hi NickSAS&lt;BR /&gt;
Find below the code how SAS provides it to create a random sample without replacement.&lt;BR /&gt;
If you analyse the small differences to your code then you see why your code doesn't really create a true random sample.&lt;BR /&gt;
Cheers, Patrick&lt;BR /&gt;
&lt;BR /&gt;
     data work.rsubset(drop=obsleft sampsize); &lt;BR /&gt;
        sampsize=10; &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;/SAMPSIZE&gt;</description>
      <pubDate>Thu, 16 Oct 2008 10:49:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-random-sample-showing-picked-observation-numbers/m-p/54583#M11581</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2008-10-16T10:49:27Z</dc:date>
    </item>
  </channel>
</rss>

