<?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: sample selection in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265815#M57915</link>
    <description>John King,
Never mind. Just leave one more choice to let OP choose .</description>
    <pubDate>Sat, 23 Apr 2016 11:49:08 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-04-23T11:49:08Z</dc:date>
    <item>
      <title>sample selection</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265394#M57871</link>
      <description>&lt;P&gt;Hello, i would like to ask you about sample selection.&lt;/P&gt;&lt;P&gt;I want to select &lt;STRONG&gt;all different&amp;nbsp;&lt;/STRONG&gt;samples from data with &lt;U&gt;no&lt;/U&gt; replacement.&lt;/P&gt;&lt;P&gt;i tried proc surveyselect with methods =srs , but i saw that some samples are same as previous, and my aim to select always different samples.&lt;/P&gt;&lt;P&gt;For example : my data is: 1,2,3,4,5&lt;/P&gt;&lt;P&gt;i want to choose all different samples, that size sample is 4, total different samples maybe : 5!/(4!*(5-4)!)=5&lt;/P&gt;&lt;P&gt;the samples will be :1,2,3,4 ; 1,2,3,5 ; 1,2,4,5; &amp;nbsp;1,3,4,5; &amp;nbsp; 2,3,4,5&lt;/P&gt;&lt;P&gt;thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 12:18:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265394#M57871</guid>
      <dc:creator>AlexeyS</dc:creator>
      <dc:date>2016-04-21T12:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: sample selection</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265395#M57872</link>
      <description>&lt;P&gt;Your not drawing a sample here, you're generating all possible combinations.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Take a look at allcomb function and routine.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 12:22:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265395#M57872</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-21T12:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: sample selection</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265397#M57873</link>
      <description>&lt;P&gt;right, but the problem with allcomb function that is not so suitable for my data.&lt;/P&gt;&lt;P&gt;my data is look like : my variable is column vector and not row. from this column vector i want create all different samples, one below each other.&lt;/P&gt;&lt;P&gt;&lt;U&gt;my data&amp;amp;colon;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;id&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;5&lt;/P&gt;&lt;P&gt;6&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 12:29:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265397#M57873</guid>
      <dc:creator>AlexeyS</dc:creator>
      <dc:date>2016-04-21T12:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: sample selection</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265407#M57874</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/42503"&gt;@AlexeyS&lt;/a&gt;,&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/42503"&gt;@AlexeyS&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;right, but the problem with allcomb function that is not so suitable for my data.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The good news is: This "problem" can be solved, as shown below.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
do id=1 to 6;
  output;
end;
run;

proc transpose data=have out=trans(drop=_:) prefix=x;
run;

%let k=4; /* sample size */

data want;
set trans;
array x x:;
ncomb=comb(dim(x), &amp;amp;k);
do sample=1 to ncomb;
  rc=allcomb(sample, &amp;amp;k, of x[*]);
  do i=1 to &amp;amp;k;
    id=x[i];
    output;
  end;
end;
keep sample id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Apr 2016 13:12:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265407#M57874</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-04-21T13:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: sample selection</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265408#M57875</link>
      <description>&lt;P&gt;I assume that you have already exhausted the possibilities of PROC SURVEYSELECT, and it won't do what you need. &amp;nbsp;In that case, here's an approach the produces one large data set with all the samples in it. &amp;nbsp;There is a variable SAMPLE that distinguishes the contents of each sample.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;do sample=1 to _nobs_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;do recno=1 to _nobs_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if sample ne recno then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;set have point=sample nobs=_nobs_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course the problem becomes more difficult if you are looking for samples of size 3 instead of samples of size "all but one". &amp;nbsp;For the "all but two" categories, you would have to add one more loop and check "if sample not in (recno, recno2) then do .. that's the reason for using point=sample rather than point=recno in the code above.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 13:15:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265408#M57875</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-04-21T13:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: sample selection</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265419#M57876</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let n=5;
%let k=4;
%let ncomb=%sysfunc(comb(&amp;amp;n,&amp;amp;k));
proc plan ordered;
   factors sample=&amp;amp;ncomb id=&amp;amp;k of &amp;amp;n comb;
   output out=C&amp;amp;k.of&amp;amp;n;
   run;
   quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/2870iB3D14B12C5603CD1/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2016 13:55:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265419#M57876</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-04-21T13:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: sample selection</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265581#M57901</link>
      <description>Why not using ALLCOMB() ?

&lt;PRE&gt;

data _null_;
array x[5] (1 2 3 4 5);
n=dim(x);
k=4;
ncomb=comb(n,k);
do j=1 to ncomb;
rc=allcomb(j, k, of x[*]);
put j 5. +3 x1-x4 +3 rc=;
end;
run;


&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Apr 2016 02:58:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265581#M57901</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-22T02:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: sample selection</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265646#M57902</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt; wrote:&lt;BR /&gt;Why not using ALLCOMB() ?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I reckon you didn't read the post from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2016 14:01:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265646#M57902</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-04-22T14:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: sample selection</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265800#M57913</link>
      <description>OH. John King, That would be easy by using a macro variable or an array to hold those data.
&lt;PRE&gt;

data have;
do id=1 to 6;
  output;
end;
run;
proc sql;
select count(*) into : n from have;
select id into : list separated by ' ' from have;
quit;
data _null_;
array x[&amp;amp;n] (&amp;amp;list);
n=dim(x);
k=4;
ncomb=comb(n,k);
do j=1 to ncomb;
rc=allcomb(j, k, of x[*]);
put j 5. +3 x1-x4 +3 rc=;
end;
run;
&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Apr 2016 02:57:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265800#M57913</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-23T02:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: sample selection</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265814#M57914</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My point is you are just repeating what was already shown earlier in the thread.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt; wrote:&lt;BR /&gt;OH. John King, That would be easy by using a macro variable or an array to hold those data.
&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Sat, 23 Apr 2016 11:40:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265814#M57914</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-04-23T11:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: sample selection</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265815#M57915</link>
      <description>John King,
Never mind. Just leave one more choice to let OP choose .</description>
      <pubDate>Sat, 23 Apr 2016 11:49:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/265815#M57915</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-23T11:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: sample selection</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/266118#M57942</link>
      <description>&lt;P&gt;thank you for your answers.&lt;/P&gt;&lt;P&gt;but i have now other problem, sometimes i have more than 33 variables, and &lt;STRONG&gt;allcomb&lt;/STRONG&gt; function cannot work.&lt;/P&gt;&lt;P&gt;as i understood, the decision is &lt;STRONG&gt;call accomb&lt;/STRONG&gt; function. but how can i use it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my code with&amp;nbsp;allcomb function :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;data have;
do id=1 to 6;
  output;
end;
run;

proc transpose data=have out=trans(drop=_:) prefix=x;
run;

%let k=4; /* sample size */

data want;
set trans;
array x x:;
ncomb=comb(dim(x), &amp;amp;k);
do sample=1 to ncomb;
  rc=allcomb(sample, &amp;amp;k, of x[*]);
  do i=1 to &amp;amp;k;
    id=x[i];
    output;
  end;
end;
keep sample id;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2016 17:12:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/266118#M57942</guid>
      <dc:creator>AlexeyS</dc:creator>
      <dc:date>2016-04-25T17:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: sample selection</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/266139#M57943</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/42503"&gt;@AlexeyS﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't need CALL ALLCOMB, but CALL ALLCOMB&lt;STRONG&gt;I&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
do id=1 to 34;
  output;
end;
run;

proc transpose data=have out=trans(drop=_:) prefix=x;
run;

%let k=4; /* sample size */

data want;
set trans;
array x x:;
array i[&amp;amp;k];
i[1]=0;
n=dim(x);
ncomb=comb(n, &amp;amp;k);
do sample=1 to ncomb;
  call allcombi(n, &amp;amp;k, of i[*]);
  do j=1 to &amp;amp;k;
    id=x[i[j]];
    output;
  end;
end;
keep sample id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Apr 2016 17:59:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sample-selection/m-p/266139#M57943</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-04-25T17:59:04Z</dc:date>
    </item>
  </channel>
</rss>

