<?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 Select random groups of observations rather unique observations in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Select-random-groups-of-observations-rather-unique-observations/m-p/143006#M38040</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table that can &lt;SPAN class="GINGER_SOFTWARE_mark" id="10d02d7a-df65-4ba0-8435-d72669e5452b"&gt;by&lt;/SPAN&gt; grouped by two variables (i.e. VARA and VARB).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I randomly select groups of observations by VARA and VARB rather than single random observations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nikos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 May 2014 19:48:00 GMT</pubDate>
    <dc:creator>Nikos</dc:creator>
    <dc:date>2014-05-02T19:48:00Z</dc:date>
    <item>
      <title>Select random groups of observations rather unique observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-random-groups-of-observations-rather-unique-observations/m-p/143006#M38040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table that can &lt;SPAN class="GINGER_SOFTWARE_mark" id="10d02d7a-df65-4ba0-8435-d72669e5452b"&gt;by&lt;/SPAN&gt; grouped by two variables (i.e. VARA and VARB).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I randomly select groups of observations by VARA and VARB rather than single random observations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nikos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 May 2014 19:48:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-random-groups-of-observations-rather-unique-observations/m-p/143006#M38040</guid>
      <dc:creator>Nikos</dc:creator>
      <dc:date>2014-05-02T19:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: Select random groups of observations rather unique observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-random-groups-of-observations-rather-unique-observations/m-p/143007#M38041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Select VARA and VARB randomly&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then subset the data table based on the random choices of VARA and VARB&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 May 2014 19:50:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-random-groups-of-observations-rather-unique-observations/m-p/143007#M38041</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2014-05-02T19:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: Select random groups of observations rather unique observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-random-groups-of-observations-rather-unique-observations/m-p/143008#M38042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data test;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;input varA varB x;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1 1 1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1 1 2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1 2 3&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1 2 4&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2 1 5&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2 1 6&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2 3 7&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2 3 8&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* Extract all unique combinations of grouping keys */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sort data=test out=keys nodupkeys; by varA varB; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* Assign a random number to each key combination */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data ranKeys;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;call streamInit(72564);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set keys;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ran = rand("UNIFORM");&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;keep varA varB ran;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* Order grouping key combinations by random variable */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sort data=ranKeys; by ran; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* Select the desired fraction of key combinations (here 50%) */&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data sampleKeys;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set ranKeys nobs=nobs;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if _n_ &amp;gt; nobs*0.5 then stop;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* Extract the data corresponding to selected key combinations */&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 want as&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select test.*&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from test natural join sampleKeys;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;select * from want;&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;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 May 2014 02:02:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-random-groups-of-observations-rather-unique-observations/m-p/143008#M38042</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-05-03T02:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: Select random groups of observations rather unique observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-random-groups-of-observations-rather-unique-observations/m-p/143009#M38043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PG,&lt;/P&gt;&lt;P&gt;After you get all unique combination of group variable, I think we could use proc selectsurvey to randomly select the group ? and merge them back to get what we need ? Your thought ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 May 2014 02:45:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-random-groups-of-observations-rather-unique-observations/m-p/143009#M38043</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-05-03T02:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: Select random groups of observations rather unique observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-random-groups-of-observations-rather-unique-observations/m-p/143010#M38044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you can do the whole thing with surveyselect, using the CLUSTER statement. - PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 May 2014 03:12:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-random-groups-of-observations-rather-unique-observations/m-p/143010#M38044</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-05-03T03:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: Select random groups of observations rather unique observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Select-random-groups-of-observations-rather-unique-observations/m-p/143011#M38045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear PG,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="GINGER_SOFTWARE_mark" id="4ca9ba0f-f857-4586-8ada-bdc9d8c3d586"&gt;Unfortunately I&lt;/SPAN&gt; do not have &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN class="GINGER_SOFTWARE_mark" id="b0f1eb79-e047-4d54-84ca-7af6f73ff520"&gt;proc selectsurvey&lt;/SPAN&gt;&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nikos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 May 2014 13:44:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Select-random-groups-of-observations-rather-unique-observations/m-p/143011#M38045</guid>
      <dc:creator>Nikos</dc:creator>
      <dc:date>2014-05-03T13:44:14Z</dc:date>
    </item>
  </channel>
</rss>

