<?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: Random in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Random/m-p/23018#M5037</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hima,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure if it's a typo or you just need a set of fresh eyes to look at this ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second AND should be OR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also note, random number streams can be tricky.&amp;nbsp; I forget all the rules, but it is quite possible that the two ranuni(111) are generating different numbers.&amp;nbsp; If you want to make sure you are comparing to the same random number, generate it first:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;newvar = ranuni(111);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then refer to newvar in the IF statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally, it looks like you have used &amp;lt; when you meant to use &amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 Mar 2012 14:54:59 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2012-03-06T14:54:59Z</dc:date>
    <item>
      <title>Random</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Random/m-p/23017#M5036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need help in coding the below scenario. I have to select only 30% of col1 population when col1 = (0,1,2)&amp;nbsp; and 70% of population when col1 = (3,4,5,6,7)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA TEMP1;&lt;/P&gt;&lt;P&gt;SET TEMP;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF (col1 in (0,1,2) and ranuni(111) &amp;lt; 0.7 )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;and (col1 in (3,4,5,6,7) and ranuni(111) &amp;lt; 0.3)&lt;P&gt;&lt;/P&gt;&lt;P&gt;then seg = 'test';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think I am missing something and I am not getting the results that I am looking for. If some one can help me, it would be awesome.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Mar 2012 14:30:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Random/m-p/23017#M5036</guid>
      <dc:creator>Hima</dc:creator>
      <dc:date>2012-03-06T14:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: Random</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Random/m-p/23018#M5037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hima,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure if it's a typo or you just need a set of fresh eyes to look at this ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second AND should be OR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also note, random number streams can be tricky.&amp;nbsp; I forget all the rules, but it is quite possible that the two ranuni(111) are generating different numbers.&amp;nbsp; If you want to make sure you are comparing to the same random number, generate it first:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;newvar = ranuni(111);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then refer to newvar in the IF statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally, it looks like you have used &amp;lt; when you meant to use &amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Mar 2012 14:54:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Random/m-p/23018#M5037</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-03-06T14:54:59Z</dc:date>
    </item>
    <item>
      <title>Re: Random</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Random/m-p/23019#M5038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's a small test program I wrote to illustrate the issue with random numbers:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;do i=1 to 1000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if ranuni(111) &amp;lt; 0.5 or ranuni(111) &amp;gt;= 0.5 then 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;You won't get 1000 records in the output data set, because the two ranuni functions generate different streams of numbers. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Mar 2012 15:14:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Random/m-p/23019#M5038</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-03-06T15:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: Random</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Random/m-p/23020#M5039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; You could avoid the intricacies of random number generation by using the sample selection proc :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Specify the sampling rates for each strata */&lt;/P&gt;&lt;P&gt;data rates;&lt;BR /&gt;input col1 _rate_ @@;&lt;BR /&gt;datalines;&lt;BR /&gt;0 .3&amp;nbsp; 1 .3&amp;nbsp; 2 .3&amp;nbsp; 3 .7&amp;nbsp; 4 .7&amp;nbsp; 5 .7&amp;nbsp; 6 .7&amp;nbsp; 7 .7&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;/* Sort the data by strata */&lt;/P&gt;&lt;P&gt;proc sort data=temp; by col1; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Extract the sample (variable Selected=1 for selected observations).&lt;/P&gt;&lt;P&gt;Remove option outall to retain only selected observations. */&lt;/P&gt;&lt;P&gt;proc surveyselect data=temp rate=rates method=srs out=temp1 outall;&lt;BR /&gt;strata col1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Mar 2012 16:37:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Random/m-p/23020#M5039</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-03-06T16:37:00Z</dc:date>
    </item>
  </channel>
</rss>

