<?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: Need to Pick Random samples of single coulmn from dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-to-Pick-Random-samples-of-single-coulmn-from-dataset/m-p/192982#M266246</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi PG,&lt;/P&gt;&lt;P&gt;Thanks for the reply and am having one more question!!! trust me this is the last one:smileylaugh:&lt;/P&gt;&lt;P&gt;Am having dataset where members went to different movies i.e there are 100 members seen movie Frozen in 2013 and 100 in 2014, 100 members seen movie Avengers in 2013 and 100 in 2014 , 100 members seen movie Titanicin 2013 and 100 in 2014. Members can repeat across movies and across 2013, 2014 that means a member can go to all three movies in 2013 and in 2014 or he can go to only one movie in 2013 and two in 2014 and a member can have multiple rows for each movie.&lt;/P&gt;&lt;P&gt;So now I need to flag 10% of distinct members for each movie, for each year&amp;nbsp; but if member is selected in movie frozen 2013&amp;nbsp; he should not be selected again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Dec 2014 19:28:23 GMT</pubDate>
    <dc:creator>rkolupoti9001</dc:creator>
    <dc:date>2014-12-03T19:28:23Z</dc:date>
    <item>
      <title>Need to Pick Random samples of single coulmn from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-Pick-Random-samples-of-single-coulmn-from-dataset/m-p/192978#M266242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;I need to pick 10% random sample of a column in a dataset&lt;/P&gt;&lt;P&gt;example:- I have 20,000 rows in a dataset and it has 200 distinct members, each member is having 100 rows so now I have to pick 10% of distinct members and my output should have all the 100 rows for that picked members.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in Advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 16:47:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-Pick-Random-samples-of-single-coulmn-from-dataset/m-p/192978#M266242</guid>
      <dc:creator>rkolupoti9001</dc:creator>
      <dc:date>2014-12-03T16:47:41Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Pick Random samples of single coulmn from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-Pick-Random-samples-of-single-coulmn-from-dataset/m-p/192979#M266243</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What you describe is cluster sampling. Use proc surveyselect:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc surveyselect data=have samprate=0.1 out=want;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;cluster member;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 16:58:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-Pick-Random-samples-of-single-coulmn-from-dataset/m-p/192979#M266243</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-12-03T16:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Pick Random samples of single coulmn from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-Pick-Random-samples-of-single-coulmn-from-dataset/m-p/192980#M266244</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi PG,&lt;/P&gt;&lt;P&gt;Thanks for the reply!!!&lt;/P&gt;&lt;P&gt;One more question Instead of extracting those random sampled members can we flag them ie, if the member is selected for random sample then mark it as "Y" else "N".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 17:28:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-Pick-Random-samples-of-single-coulmn-from-dataset/m-p/192980#M266244</guid>
      <dc:creator>rkolupoti9001</dc:creator>
      <dc:date>2014-12-03T17:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Pick Random samples of single coulmn from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-Pick-Random-samples-of-single-coulmn-from-dataset/m-p/192981#M266245</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, use the OUTALL option, the SELECTED variable will = 1 if selected and 0 otherwise :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc surveyselect data=have samprate=0.1 out=want outall;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;cluster member;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 17:55:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-Pick-Random-samples-of-single-coulmn-from-dataset/m-p/192981#M266245</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-12-03T17:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Pick Random samples of single coulmn from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-Pick-Random-samples-of-single-coulmn-from-dataset/m-p/192982#M266246</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi PG,&lt;/P&gt;&lt;P&gt;Thanks for the reply and am having one more question!!! trust me this is the last one:smileylaugh:&lt;/P&gt;&lt;P&gt;Am having dataset where members went to different movies i.e there are 100 members seen movie Frozen in 2013 and 100 in 2014, 100 members seen movie Avengers in 2013 and 100 in 2014 , 100 members seen movie Titanicin 2013 and 100 in 2014. Members can repeat across movies and across 2013, 2014 that means a member can go to all three movies in 2013 and in 2014 or he can go to only one movie in 2013 and two in 2014 and a member can have multiple rows for each movie.&lt;/P&gt;&lt;P&gt;So now I need to flag 10% of distinct members for each movie, for each year&amp;nbsp; but if member is selected in movie frozen 2013&amp;nbsp; he should not be selected again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 19:28:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-Pick-Random-samples-of-single-coulmn-from-dataset/m-p/192982#M266246</guid>
      <dc:creator>rkolupoti9001</dc:creator>
      <dc:date>2014-12-03T19:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: Need to Pick Random samples of single coulmn from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-Pick-Random-samples-of-single-coulmn-from-dataset/m-p/192983#M266247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am afraid this is not as easy. One way would be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* Compute the number of members to sample for each movie and year */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table memberPick as&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select movie, year, round(0.1*count(distinct member)) as _nsize_&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from have&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;group by movie, year;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* Select a random movie and year for each member */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data have0;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;order = rand("uniform");&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sort data=have0; by member order; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data have1;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set have0; by member;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if first.member;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;drop order;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* Sample members for each movie and year */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sort data=have1; by movie year; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc surveyselect data=have1 sampsize=memberPick out=want outall;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;strata movie year;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 22:00:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-Pick-Random-samples-of-single-coulmn-from-dataset/m-p/192983#M266247</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-12-03T22:00:21Z</dc:date>
    </item>
  </channel>
</rss>

