<?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: Set proportions for randomly generated numbers in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Set-proportions-for-randomly-generated-numbers/m-p/601272#M16704</link>
    <description>&lt;P&gt;You can also look up the rand('table') option when you have variables that have different predetermined probability.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/298046"&gt;@SASNewbie7&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm in a data management class right now and have been given the following assignment:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create a temporary SAS dataset with 7000 observations containing a numeric subject number (beginning with 1), a randomly generated marital status (use CALL STREAMINIT and the RAND function with a uniform distribution) with the following proportions: married 65%, single 25%, divorced 10% and a randomly generated age (integer) ranging from 25 to 50 inclusive. Compute the frequencies for marital status and age to confirm values have been appropriately assigned. Print the first 20 observations. {BONUS 5 points: review and comment on the relationship between age and marital status. Within each age, is marital status approximately 65% married, 25% single, and 10% divorced?&amp;nbsp; Why or why not?}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have thus far developed the following code:&lt;/P&gt;
&lt;P&gt;data temp;&lt;BR /&gt;call streaminit(1234567);&lt;BR /&gt;do Subj = 1 to 7000;&lt;BR /&gt;marital = ceil(rand("uniform", 0, 3));&lt;BR /&gt;age = ceil(rand("uniform", 24, 50));&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;proc freq data = temp;&lt;BR /&gt;tables marital age;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I adjust the proportions of the marital variable so that the random numbers generate in the specified proportions described above? They are currently generating in a 33% proportion for each number 1-3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 03 Nov 2019 23:29:22 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-11-03T23:29:22Z</dc:date>
    <item>
      <title>Set proportions for randomly generated numbers</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Set-proportions-for-randomly-generated-numbers/m-p/601256#M16700</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm in a data management class right now and have been given the following assignment:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create a temporary SAS dataset with 7000 observations containing a numeric subject number (beginning with 1), a randomly generated marital status (use CALL STREAMINIT and the RAND function with a uniform distribution) with the following proportions: married 65%, single 25%, divorced 10% and a randomly generated age (integer) ranging from 25 to 50 inclusive. Compute the frequencies for marital status and age to confirm values have been appropriately assigned. Print the first 20 observations. {BONUS 5 points: review and comment on the relationship between age and marital status. Within each age, is marital status approximately 65% married, 25% single, and 10% divorced?&amp;nbsp; Why or why not?}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have thus far developed the following code:&lt;/P&gt;&lt;P&gt;data temp;&lt;BR /&gt;call streaminit(1234567);&lt;BR /&gt;do Subj = 1 to 7000;&lt;BR /&gt;marital = ceil(rand("uniform", 0, 3));&lt;BR /&gt;age = ceil(rand("uniform", 24, 50));&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;proc freq data = temp;&lt;BR /&gt;tables marital age;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I adjust the proportions of the marital variable so that the random numbers generate in the specified proportions described above? They are currently generating in a 33% proportion for each number 1-3.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Nov 2019 21:47:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Set-proportions-for-randomly-generated-numbers/m-p/601256#M16700</guid>
      <dc:creator>SASNewbie7</dc:creator>
      <dc:date>2019-11-03T21:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: Set proportions for randomly generated numbers</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Set-proportions-for-randomly-generated-numbers/m-p/601263#M16703</link>
      <description>&lt;P&gt;Use the rand('uniform') function. If the result is 0 to 0.65, this is "married", 0.65 to 0.9 as "single", and 0.9 to 1.0 is "divorced".&lt;/P&gt;</description>
      <pubDate>Sun, 03 Nov 2019 22:49:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Set-proportions-for-randomly-generated-numbers/m-p/601263#M16703</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-03T22:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: Set proportions for randomly generated numbers</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Set-proportions-for-randomly-generated-numbers/m-p/601272#M16704</link>
      <description>&lt;P&gt;You can also look up the rand('table') option when you have variables that have different predetermined probability.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/298046"&gt;@SASNewbie7&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm in a data management class right now and have been given the following assignment:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create a temporary SAS dataset with 7000 observations containing a numeric subject number (beginning with 1), a randomly generated marital status (use CALL STREAMINIT and the RAND function with a uniform distribution) with the following proportions: married 65%, single 25%, divorced 10% and a randomly generated age (integer) ranging from 25 to 50 inclusive. Compute the frequencies for marital status and age to confirm values have been appropriately assigned. Print the first 20 observations. {BONUS 5 points: review and comment on the relationship between age and marital status. Within each age, is marital status approximately 65% married, 25% single, and 10% divorced?&amp;nbsp; Why or why not?}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have thus far developed the following code:&lt;/P&gt;
&lt;P&gt;data temp;&lt;BR /&gt;call streaminit(1234567);&lt;BR /&gt;do Subj = 1 to 7000;&lt;BR /&gt;marital = ceil(rand("uniform", 0, 3));&lt;BR /&gt;age = ceil(rand("uniform", 24, 50));&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;proc freq data = temp;&lt;BR /&gt;tables marital age;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I adjust the proportions of the marital variable so that the random numbers generate in the specified proportions described above? They are currently generating in a 33% proportion for each number 1-3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Nov 2019 23:29:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Set-proportions-for-randomly-generated-numbers/m-p/601272#M16704</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-03T23:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: Set proportions for randomly generated numbers</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Set-proportions-for-randomly-generated-numbers/m-p/601429#M16719</link>
      <description>&lt;P&gt;Marital = rand('table', 0.65, 0.25, 0.10);&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2019 16:28:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Set-proportions-for-randomly-generated-numbers/m-p/601429#M16719</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-11-04T16:28:18Z</dc:date>
    </item>
  </channel>
</rss>

