<?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 alphanumeric values in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-alphanumeric-values/m-p/211367#M52209</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One way, possibly not the slickest:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; retain pos;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _n_ = 1 then pos= mod(rand('table', 0.25, 0.25, 0.25, 0.25),4);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else pos = mod(pos+1,4);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select (pos);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when(0) sequence='X1';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when(1) sequence='Y1';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when(2) sequence='X2';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when(3) sequence='Y2';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; otherwise;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;You may want to drop the POS variable. Alternatively, skip the select and assignment to sequence and use a custom format on the POS variable (named as you like) that would display the X1, Y1 etc. That would actually be my choice.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 22 Jun 2015 15:49:48 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2015-06-22T15:49:48Z</dc:date>
    <item>
      <title>Assigning alphanumeric values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-alphanumeric-values/m-p/211365#M52207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi, I want to assign a value in the sequence {X1, Y1, X2, Y2}, starting with a random value from that sequence then cycle through the sequence over and over for the number of observations. For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if the random value from the sequence {X1, Y1, X2, Y2} is Y1, then the next value should be X2, then Y2, then X1, then Y1, then X2 and so on.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure how to do the alphanumeric assignment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Josh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 15:28:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-alphanumeric-values/m-p/211365#M52207</guid>
      <dc:creator>jprosenbaum8908</dc:creator>
      <dc:date>2015-06-22T15:28:02Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning alphanumeric values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-alphanumeric-values/m-p/211366#M52208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Set up a temporary array to hold your sequence. Then use a random distribution to get your first index and then increment from there, using the mod function to stay within the limits of your array.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;do i=1 to 100;&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;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;array seq(4) $ _temporary_ ("X1" "Y1" "X2" "Y2");&lt;/P&gt;&lt;P&gt;retain start;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if _n_=1 then start=floor(rand('uniform')*dim(seq))+1;&lt;/P&gt;&lt;P&gt;else start=mod(start,dim(seq))+1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sequence=seq(start);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 15:49:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-alphanumeric-values/m-p/211366#M52208</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-06-22T15:49:34Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning alphanumeric values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-alphanumeric-values/m-p/211367#M52209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One way, possibly not the slickest:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; retain pos;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _n_ = 1 then pos= mod(rand('table', 0.25, 0.25, 0.25, 0.25),4);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else pos = mod(pos+1,4);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select (pos);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when(0) sequence='X1';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when(1) sequence='Y1';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when(2) sequence='X2';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; when(3) sequence='Y2';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; otherwise;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;You may want to drop the POS variable. Alternatively, skip the select and assignment to sequence and use a custom format on the POS variable (named as you like) that would display the X1, Y1 etc. That would actually be my choice.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 15:49:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-alphanumeric-values/m-p/211367#M52209</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-06-22T15:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning alphanumeric values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-alphanumeric-values/m-p/211368#M52210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Simple task:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do i = 1 to 10; output; end;&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 want;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;array values{4} $ _temporary_ ("X1", "Y1", "X2", "Y2");&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if rndOffset=0 then rndOffset + ceil(dim(values)*rand("UNIFORM"));&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set have;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;rndValue = values{1 + mod(_n_ + rndOffset, dim(values))};&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;drop rndOffset;&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;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 15:58:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-alphanumeric-values/m-p/211368#M52210</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-06-22T15:58:21Z</dc:date>
    </item>
  </channel>
</rss>

