<?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: Assigning repeated values for a variable in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-repeated-values-for-a-variable/m-p/202482#M50529</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, yes that worked.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Jun 2015 18:40:19 GMT</pubDate>
    <dc:creator>jprosenbaum8908</dc:creator>
    <dc:date>2015-06-10T18:40:19Z</dc:date>
    <item>
      <title>Assigning repeated values for a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-repeated-values-for-a-variable/m-p/202479#M50526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Let's say I have 100 Temporary Employees, variable label TE, and they are assigned a number 1 -100. I want to assign the Temp Employ a Rotation number, variable label RO, of 1 through 3 repeatedly and have it start with a random rotation number. So if the random number generated for the first TE is RO = 2, I want the next RO=3, then start the cycle over of assigning RO of 1-3 for the rest of the TEs. I know this is basic, but I am struggling how to write this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here is my example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data haveemp;&lt;/P&gt;&lt;P&gt;INPUT TE;&lt;/P&gt;&lt;P&gt;Datalines;&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&lt;/P&gt;&lt;P&gt;7&lt;/P&gt;&lt;P&gt;8&lt;/P&gt;&lt;P&gt;9&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P&gt;11&lt;/P&gt;&lt;P&gt;12&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data wantrot;&lt;/P&gt;&lt;P&gt;length RO 8;&lt;/P&gt;&lt;P&gt;set haveemp;&lt;/P&gt;&lt;P&gt;if TE = 1 then RO = ceil(4*ranuni(0));&lt;/P&gt;&lt;P&gt;Do i = 2 to 12;&lt;/P&gt;&lt;P&gt;...&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;I am not sure what to do after the do statement. I have a mod(n-1,3)+1 type of thinking for the other ROs but I am not sure how to ensure a proper cycle with the random number generated for the first TE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be appreciated. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jun 2015 16:45:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-repeated-values-for-a-variable/m-p/202479#M50526</guid>
      <dc:creator>jprosenbaum8908</dc:creator>
      <dc:date>2015-06-10T16:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning repeated values for a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-repeated-values-for-a-variable/m-p/202480#M50527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I like PROC PLAN for this.&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;_null_&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; streaminit(&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;34567&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; symputx(&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'ib'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,rand(&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'table'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;/&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;3&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;/&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;3&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;));&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; NOTE: &amp;amp;=ib &amp;amp;=sysrandom;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;plan&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;seed&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;998877&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;factors&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; to=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;100&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;ordered&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; ro=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;of&lt;/SPAN&gt; &lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;3&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;cyclic&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;(&amp;amp;ib) /&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;noprint&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;output&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;out&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=plan;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;quit&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;print&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;; &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;IMG alt="6-10-2015 12-32-46 PM.png" class="jive-image" src="https://communities.sas.com/legacyfs/online/10794_6-10-2015 12-32-46 PM.png" /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jun 2015 17:34:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-repeated-values-for-a-variable/m-p/202480#M50527</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-06-10T17:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning repeated values for a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-repeated-values-for-a-variable/m-p/202481#M50528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe something like this:&lt;/P&gt;&lt;PRE&gt;127&amp;nbsp; data want;
128&amp;nbsp;&amp;nbsp;&amp;nbsp; set haveemp;
129&amp;nbsp;&amp;nbsp;&amp;nbsp; retain RO;
130&amp;nbsp;&amp;nbsp;&amp;nbsp; if TE=1 then RO=ceil(3*ranuni(0));
131&amp;nbsp;&amp;nbsp;&amp;nbsp; else RO=mod(RO,3)+1;
132&amp;nbsp;&amp;nbsp;&amp;nbsp; put _all_;
133&amp;nbsp; run;

TE=1 RO=3 _ERROR_=0 _N_=1
TE=2 RO=1 _ERROR_=0 _N_=2
TE=3 RO=2 _ERROR_=0 _N_=3
TE=4 RO=3 _ERROR_=0 _N_=4
TE=5 RO=1 _ERROR_=0 _N_=5
TE=6 RO=2 _ERROR_=0 _N_=6
TE=7 RO=3 _ERROR_=0 _N_=7
TE=8 RO=1 _ERROR_=0 _N_=8
TE=9 RO=2 _ERROR_=0 _N_=9
TE=10 RO=3 _ERROR_=0 _N_=10
TE=11 RO=1 _ERROR_=0 _N_=11
TE=12 RO=2 _ERROR_=0 _N_=12

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jun 2015 17:38:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-repeated-values-for-a-variable/m-p/202481#M50528</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2015-06-10T17:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning repeated values for a variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-repeated-values-for-a-variable/m-p/202482#M50529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, yes that worked.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jun 2015 18:40:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-repeated-values-for-a-variable/m-p/202482#M50529</guid>
      <dc:creator>jprosenbaum8908</dc:creator>
      <dc:date>2015-06-10T18:40:19Z</dc:date>
    </item>
  </channel>
</rss>

