<?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 to do a unrestricted random sample of multiple variables in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203621#M10923</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone.&amp;nbsp; I have a dataset that has has a variable I would like to do a random sample with replacement from.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The trick is, the dataset has a grouping variable State.&amp;nbsp; I would like to do a random sample of 10,000 observations on the same variable for EACH state, so that at the end of the day my dataset would have 10,000 * 50 or 500,000 observations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think surveyselect can do this but if I am incorrect please let me know. I found this code for doing Random sample with replacement, but all of my attempts to get it to run "by groups" fails.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Random Sample with Replacement code... Want to repeat it by groups.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA SRS_WR/ ;&lt;/P&gt;&lt;P&gt;SEED=123466;&lt;/P&gt;&lt;P&gt;SamplingProbability=&amp;amp;SAMPLE_SIZE/FRAME_SIZE;&lt;/P&gt;&lt;P&gt;SamplingWeight=1/SamplingProbability;&lt;/P&gt;&lt;P&gt;DO samp_cnt=1 TO &amp;amp;sample_size;&lt;/P&gt;&lt;P&gt;SELECT=CEIL( UNIFORM(SEED) * FRAME_SIZE );&lt;/P&gt;&lt;P&gt;SET ResidualsDists POINT=SELECT NOBS=FRAME_SIZE;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;stop;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I could also put this into a macro loop and repeat the code that way, however that seems very inefficient and I imagine there is a way to get it to work using "by groups".&amp;nbsp; If anyone can provide help it would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example of my data (very small example).Value&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data MetricLocation;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; infile datalines delimiter=','; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input State $ MEtricDist;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; datalines;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;CA,506&lt;/P&gt;&lt;P&gt;CA,45&lt;/P&gt;&lt;P&gt;CA,41&lt;/P&gt;&lt;P&gt;CA,32&lt;/P&gt;&lt;P&gt;CA,49&lt;/P&gt;&lt;P&gt;CA,45&lt;/P&gt;&lt;P&gt;CA,38&lt;/P&gt;&lt;P&gt;CA,20&lt;/P&gt;&lt;P&gt;CA,61&lt;/P&gt;&lt;P&gt;CA,64&lt;/P&gt;&lt;P&gt;CA,305&lt;/P&gt;&lt;P&gt;CA,42&lt;/P&gt;&lt;P&gt;CO,506&lt;/P&gt;&lt;P&gt;CO,46&lt;/P&gt;&lt;P&gt;CO,42&lt;/P&gt;&lt;P&gt;CO,33&lt;/P&gt;&lt;P&gt;CO,50&lt;/P&gt;&lt;P&gt;CO,51&lt;/P&gt;&lt;P&gt;CO,62&lt;/P&gt;&lt;P&gt;CO,60&lt;/P&gt;&lt;P&gt;CO,55&lt;/P&gt;&lt;P&gt;CO,49&lt;/P&gt;&lt;P&gt;CO,53&lt;/P&gt;&lt;P&gt;CO,51&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 Mar 2015 16:37:07 GMT</pubDate>
    <dc:creator>Anotherdream</dc:creator>
    <dc:date>2015-03-17T16:37:07Z</dc:date>
    <item>
      <title>How to do a unrestricted random sample of multiple variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203621#M10923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone.&amp;nbsp; I have a dataset that has has a variable I would like to do a random sample with replacement from.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The trick is, the dataset has a grouping variable State.&amp;nbsp; I would like to do a random sample of 10,000 observations on the same variable for EACH state, so that at the end of the day my dataset would have 10,000 * 50 or 500,000 observations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think surveyselect can do this but if I am incorrect please let me know. I found this code for doing Random sample with replacement, but all of my attempts to get it to run "by groups" fails.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Random Sample with Replacement code... Want to repeat it by groups.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA SRS_WR/ ;&lt;/P&gt;&lt;P&gt;SEED=123466;&lt;/P&gt;&lt;P&gt;SamplingProbability=&amp;amp;SAMPLE_SIZE/FRAME_SIZE;&lt;/P&gt;&lt;P&gt;SamplingWeight=1/SamplingProbability;&lt;/P&gt;&lt;P&gt;DO samp_cnt=1 TO &amp;amp;sample_size;&lt;/P&gt;&lt;P&gt;SELECT=CEIL( UNIFORM(SEED) * FRAME_SIZE );&lt;/P&gt;&lt;P&gt;SET ResidualsDists POINT=SELECT NOBS=FRAME_SIZE;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;stop;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I could also put this into a macro loop and repeat the code that way, however that seems very inefficient and I imagine there is a way to get it to work using "by groups".&amp;nbsp; If anyone can provide help it would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example of my data (very small example).Value&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data MetricLocation;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; infile datalines delimiter=','; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input State $ MEtricDist;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; datalines;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;CA,506&lt;/P&gt;&lt;P&gt;CA,45&lt;/P&gt;&lt;P&gt;CA,41&lt;/P&gt;&lt;P&gt;CA,32&lt;/P&gt;&lt;P&gt;CA,49&lt;/P&gt;&lt;P&gt;CA,45&lt;/P&gt;&lt;P&gt;CA,38&lt;/P&gt;&lt;P&gt;CA,20&lt;/P&gt;&lt;P&gt;CA,61&lt;/P&gt;&lt;P&gt;CA,64&lt;/P&gt;&lt;P&gt;CA,305&lt;/P&gt;&lt;P&gt;CA,42&lt;/P&gt;&lt;P&gt;CO,506&lt;/P&gt;&lt;P&gt;CO,46&lt;/P&gt;&lt;P&gt;CO,42&lt;/P&gt;&lt;P&gt;CO,33&lt;/P&gt;&lt;P&gt;CO,50&lt;/P&gt;&lt;P&gt;CO,51&lt;/P&gt;&lt;P&gt;CO,62&lt;/P&gt;&lt;P&gt;CO,60&lt;/P&gt;&lt;P&gt;CO,55&lt;/P&gt;&lt;P&gt;CO,49&lt;/P&gt;&lt;P&gt;CO,53&lt;/P&gt;&lt;P&gt;CO,51&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 16:37:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203621#M10923</guid>
      <dc:creator>Anotherdream</dc:creator>
      <dc:date>2015-03-17T16:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a unrestricted random sample of multiple variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203622#M10924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I may be missing something but this seems like a simple Surveyselect with a strata statement?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc surveyselect data = metricLocation out=metricSample method=SRS sampsize=7;&lt;/P&gt;&lt;P&gt;strata state;&lt;/P&gt;&lt;P&gt;run;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 17:12:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203622#M10924</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-03-17T17:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a unrestricted random sample of multiple variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203623#M10925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey @Reeza. As always thanks for your help.&amp;nbsp; I thought the same thing, but if you only have say 10 observations in one subset and you want to do a random sample of "20" (with replacement) then SRS doesn't work sadly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;however I just tried&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc surveyselect data=ResidualsDists&lt;BR /&gt;rep=1 seed=69581 outhits&lt;BR /&gt;&amp;nbsp;&amp;nbsp; method=urs sampsize=500 out=SampleSRS;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; strata State;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And it does seem to work.&amp;nbsp;&amp;nbsp; I am curious if there is a way to do a surveyselect maintaining inherent order however?&amp;nbsp;&amp;nbsp; If you run the following example, it will repeat the metric value X times, wehre X was the number of times it was sampled.&amp;nbsp; So in our example if "506" was sampled 88 times, it would repeat 506 88 times, and then it would list 45 X times ( where X is the total number of times out of 500 it was sampled).&amp;nbsp; I would prefer to not do this but instead actual maintain the order of the sample.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So if the sample went "506" "61" "20" " 64" "64" "506" for california it would be nice to maintain that ordering.&amp;nbsp; Do you know if Survey select can do this? (I am starting to think more of sampling Multiple X variables that might be correlated).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 17:22:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203623#M10925</guid>
      <dc:creator>Anotherdream</dc:creator>
      <dc:date>2015-03-17T17:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a unrestricted random sample of multiple variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203624#M10926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Add a record order variable or what ever you want to call it before surveyselect and add it and any other variables you want from to an ID statement;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;id order var1 var2;&lt;/P&gt;&lt;P&gt;IF the order variable contains the order you want you may just need to resort after the selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would hope that if you are requesting a 10000 sample size that you have more than 20 records in the strata. If that is an issue you may want to look at SAMPRATE instead of SIZE...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 17:37:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203624#M10926</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-03-17T17:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a unrestricted random sample of multiple variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203625#M10927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Ballardw. Thanks to you as well for your help!&amp;nbsp; I think more clarification on my actual problem would be helpful, as I tried to simplify it down quite a bit (maybe too much) to answer one part of multiple problems I am having.&amp;nbsp; By the way your use of the "ID" variable may be exactly what I need, and i'll look into that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically I have 4 datasets which each have a variable, and also have the variable "state".&amp;nbsp; I want to create a new variable which is a transformation and combination of the 4 underlying variable distributions.&amp;nbsp; Unfortunately some of the distributions are not normal (one is bi-model, another is non-defined, etc..).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In school I was taught a great way to do this is Monte carlo simulation. Basically pick randomly from EACH of the distributions (once) and then perform your transformation.&amp;nbsp; The resulting value is 1 'observation' from the distribution that you want.&amp;nbsp;&amp;nbsp; Repeat this process 10k times, and the resulting distribution is the final variable 'distribution' that you are interested in.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am struggling with survey select, because it maintains orders of the variables from the input dataset and instead outputs the 'probability' of selection, and number of times selected.&amp;nbsp; This is&lt;STRONG&gt; not good&lt;/STRONG&gt; for what I am trying to do, since smaller values of a variable A could be grouped with smaller values of Variable B for no reason other than the way survey select seems to work (if they happened to be ordered smallest to largest by example before the survey select ran).&amp;nbsp; I would have then effectively added a "correlation" between the random variable distributions without meaning too.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wasn't sure how to solve this problem and that is where the question came from.&amp;nbsp; I tried to simplify it to find a way to do a random sample By Group without surveySelect....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think the answer to my question is found below (now).&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If i want the 4 underlying distributions to be independent of eachother in their samples.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do the survey select for each of the 4 datasets, and then just randomly order the results of each result set. That way observation 1 from each random sample from the distribution could be added together to get a new "Distribution 5", and they would still be independently generated from their own distributions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does that sound reasonable to you?&amp;nbsp; I didn't really think this was a good solution because you have to do a random sample, and then randomly sort your result set... I was surprised that sas didn't already have a function that would do this for you to be honest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if I am not being clear enough!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 17:49:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203625#M10927</guid>
      <dc:creator>Anotherdream</dc:creator>
      <dc:date>2015-03-17T17:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a unrestricted random sample of multiple variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203626#M10928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote" modifiedtitle="true"&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I thought the same thing, but if you only have say 10 observations in one subset and you want to do a random sample of "20" (with replacement) then SRS doesn't work sadly.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;With Replacement it should work. You can also look at the SELECTALL option:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P&gt;&lt;STRONG&gt;SELECTALL &lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin: 0 5px 1.4em;"&gt;&lt;A class="syntaxindex" id="statug.surveyselect.a0000000075" style="font-family: inherit;"&gt;&lt;/A&gt;&lt;A class="syntaxindex" id="statug.surveyselect.a0000000076" style="font-family: inherit;"&gt;&lt;/A&gt;requests that PROC SURVEYSELECT select all stratum units when the stratum sample size exceeds the total number of units in the stratum. By default, PROC SURVEYSELECT does not allow you to specify a stratum sample size that is greater than the total number of units in the stratum, unless you are using a with-replacement selection method. &lt;/P&gt;
&lt;P style="margin: 0 5px 1.4em;"&gt;The SELECTALL option is available for the following without-replacement selection methods: &lt;A href="http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/statug_surveyselect_sect007.htm#statug.surveyselect.methodsrs" style="color: #000066;"&gt;METHOD=SRS&lt;/A&gt;, &lt;A href="http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/statug_surveyselect_sect007.htm#statug.surveyselect.methodsys" style="color: #000066;"&gt;METHOD=SYS&lt;/A&gt;, &lt;A href="http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/statug_surveyselect_sect007.htm#statug.surveyselect.methodseq" style="color: #000066;"&gt;METHOD=SEQ&lt;/A&gt;, &lt;A href="http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/statug_surveyselect_sect007.htm#statug.surveyselect.methodpps" style="color: #000066;"&gt;METHOD=PPS&lt;/A&gt;, and &lt;A href="http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/statug_surveyselect_sect007.htm#statug.surveyselect.methodsampford" style="color: #000066;"&gt;METHOD=PPS_SAMPFORD&lt;/A&gt;. &lt;/P&gt;
&lt;P style="margin: 0 5px 1.4em;"&gt;The SELECTALL option is not available for with-replacement selection methods, with-minimum-replacement methods, or those PPS methods that select two units per stratum.&lt;/P&gt;
&lt;/PRE&gt;&lt;P style="margin: 0 5px 1.4em;"&gt;&lt;/P&gt;&lt;P style="margin: 0 5px 1.4em;"&gt;For the Order you can use either @ballardW solution's or consider looking at the OUTALL option which outputs the entire dataset with a 1/0 to indicate selection. I'm not sure of the order of the data though. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 17:52:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203626#M10928</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-03-17T17:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a unrestricted random sample of multiple variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203627#M10929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've not noticed any order imposed on ID variables. The order of the STRATA variables is sort of required. Another option to consider if order is important would be to use Method=SYS.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 19:40:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203627#M10929</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-03-17T19:40:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a unrestricted random sample of multiple variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203628#M10930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What I mean is. The output distribution of your variables is deterministic in it's output (but not it's results) when using proc surveyselect.&amp;nbsp;&amp;nbsp; Even without using strata.&amp;nbsp;&amp;nbsp; Please see thw following example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data MetricLocation;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; infile datalines delimiter=','; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input MEtricDist;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; datalines;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;506&lt;/P&gt;&lt;P&gt;45&lt;/P&gt;&lt;P&gt;41&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;proc surveyselect data=MetricLocation&lt;/P&gt;&lt;P&gt;rep=1 seed=69581 outhits&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; method=urs sampsize=500 out=SampleSRS;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will note the output dataset has the variable "metricDist" with a value of "506" repeated 145 times (number of hits 145). 45 repeated 196 times, and then 41 159 times.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now the true order of the simulation could have been 506, 506, 45, 41, 45, 45, 506, 506, etc... But it is ordered by the MetricDist columns original distribution.. I don't want this.&amp;nbsp; I am still not 100% sure how to fix this problem.&amp;nbsp; I am working on the ID variable but am not sure I am doing it correctly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 21:06:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203628#M10930</guid>
      <dc:creator>Anotherdream</dc:creator>
      <dc:date>2015-03-17T21:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a unrestricted random sample of multiple variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203629#M10931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can reorder the output: Add in a random number from that oversampled data and then sort on strata and that order variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 21:53:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203629#M10931</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-03-17T21:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a unrestricted random sample of multiple variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203630#M10932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You'll probably need to use a different solution then....the Point solution above may work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mine would probably be more roundabout - I'd generate a set of random numbers that had the format I was looking for based on my rules and then merge my data in based on a record ID. I have no idea on the efficiency of this, but perhaps the solution you initially posted matches this or perhaps someone can improve on it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc freq data=have noprint;&lt;/P&gt;&lt;P&gt;table state/out=stateCNT;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data sample;&lt;/P&gt;&lt;P&gt;set stateCNT;&lt;/P&gt;&lt;P&gt;seed=10;&lt;/P&gt;&lt;P&gt;do i=1 to 500; *number of samples;&lt;/P&gt;&lt;P&gt;record=count*ranuni(seed)+1;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then merge into records.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 02:43:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203630#M10932</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-03-18T02:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a unrestricted random sample of multiple variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203631#M10933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What you want then is a random sequence, not a random sample. This, for instance, works fine&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data MetricLocation;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; infile datalines delimiter=',';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; input State $ MEtricDist;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; datalines;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CA,506&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CA,45&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CA,41&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CA,32&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CA,49&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CA,45&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CO,506&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CO,46&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CO,42&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CO,33&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CO,50&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CO,51&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc surveyselect data=MetricLocation method=urs out=sample sampsize=10 seed=1764;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;strata state;&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;data rndSample;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;call streaminit(86785);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set sample;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do i = 1 to numberHits;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rnd = rand("UNIFORM");&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;drop NumberHits ExpectedHits SamplingWeight i;&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=rndSample out=randomSequence(drop=rnd); by State rnd; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc print data=randomSequence; 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, 18 Mar 2015 03:23:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203631#M10933</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-03-18T03:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a unrestricted random sample of multiple variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203632#M10934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello PGStats.&amp;nbsp; This is exactly what I wanted!&amp;nbsp; I think I was more surprised that SAS didn't have a built in function to do something like this.&amp;nbsp; However if you think this is the best way to do it, so be It! I will use this methodology.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your time!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Mar 2015 16:06:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-do-a-unrestricted-random-sample-of-multiple-variables/m-p/203632#M10934</guid>
      <dc:creator>Anotherdream</dc:creator>
      <dc:date>2015-03-18T16:06:40Z</dc:date>
    </item>
  </channel>
</rss>

