<?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 can I extract sample with desired statistics in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-extract-sample-with-desired-statistics/m-p/343997#M79021</link>
    <description>&lt;P&gt;I have 1million people's score.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each people's score is between 400 and 650;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to extract sample(exactly 2858 person's score information) and I also want sample score's average is 564.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I extract this information??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any helps and tips will be much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks, Jamie.&lt;/P&gt;</description>
    <pubDate>Fri, 24 Mar 2017 09:42:26 GMT</pubDate>
    <dc:creator>jamie0111</dc:creator>
    <dc:date>2017-03-24T09:42:26Z</dc:date>
    <item>
      <title>How can I extract sample with desired statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-extract-sample-with-desired-statistics/m-p/343997#M79021</link>
      <description>&lt;P&gt;I have 1million people's score.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each people's score is between 400 and 650;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to extract sample(exactly 2858 person's score information) and I also want sample score's average is 564.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I extract this information??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any helps and tips will be much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks, Jamie.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2017 09:42:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-extract-sample-with-desired-statistics/m-p/343997#M79021</guid>
      <dc:creator>jamie0111</dc:creator>
      <dc:date>2017-03-24T09:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: How can I extract sample with desired statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-extract-sample-with-desired-statistics/m-p/344032#M79028</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/How-to-random-sample-with-desired-aggregate-statistics/m-p/343977#M79011" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/How-to-random-sample-with-desired-aggregate-statistics/m-p/343977#M79011&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2017 11:27:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-extract-sample-with-desired-statistics/m-p/344032#M79028</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-03-24T11:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: How can I extract sample with desired statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-extract-sample-with-desired-statistics/m-p/344088#M79049</link>
      <description>&lt;P&gt;How close to 564 must it be? If you require exactly that you may be spending some time. Do you have a desired range on the values? Standard deviation&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And is this supposed to be anything resembling a random sample?&lt;/P&gt;
&lt;P&gt;If not, then how many values do you have in the data that are 564. If the number is &amp;gt; 2858 then just grab them. Likely not actually useful for your purpose but would fit the bare bones of your request.&lt;/P&gt;
&lt;P&gt;Or 1429 each of values 563 and 565&lt;/P&gt;
&lt;P&gt;Or many other selections would have the desired mean.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would probably start with&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc surveyselect data=have out=want sampsize=2858;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc mean data=want ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var score;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;And see if the mean is "close enough".&lt;/P&gt;
&lt;P&gt;This is cheap enough in time that you could even re-run the above code until you got something close.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2017 14:50:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-extract-sample-with-desired-statistics/m-p/344088#M79049</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-24T14:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: How can I extract sample with desired statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-extract-sample-with-desired-statistics/m-p/344392#M79139</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The 2858 sample score's average does not have to be exactly 564.&lt;/P&gt;&lt;P&gt;I will do sampling many times until I have average 560~570.&lt;/P&gt;&lt;P&gt;Anyway, thanks for your big help!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Mar 2017 07:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-extract-sample-with-desired-statistics/m-p/344392#M79139</guid>
      <dc:creator>jamie0111</dc:creator>
      <dc:date>2017-03-26T07:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: How can I extract sample with desired statistics</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-extract-sample-with-desired-statistics/m-p/344483#M79166</link>
      <description>&lt;P&gt;I can suggest that if you use startified sampling, the sampling observations can be read according to sampling weight.&lt;/P&gt;&lt;P&gt;Hopefully this code works for you.&lt;/P&gt;&lt;P&gt;%macro do_sampling;&lt;BR /&gt;%do %until (&amp;amp;avg_score ge 560 and &amp;amp;avg_score le 564);&lt;BR /&gt;proc surveyselect data=sort_sample&lt;BR /&gt;method=srs n=2858&lt;BR /&gt;seed=1234 out=sample_customer;&lt;BR /&gt;strata score;&lt;BR /&gt;run;&lt;BR /&gt;proc sql;&lt;BR /&gt;select avg(score) into :avg_score from sort_sample;&lt;BR /&gt;quit;&lt;BR /&gt;%put &amp;amp;avg_score;&lt;BR /&gt;%end;&lt;BR /&gt;%mend do_sampling;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 01:31:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-extract-sample-with-desired-statistics/m-p/344483#M79166</guid>
      <dc:creator>lakshmi_74</dc:creator>
      <dc:date>2017-03-27T01:31:14Z</dc:date>
    </item>
  </channel>
</rss>

