<?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 Choosing random character value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Choosing-random-character-value/m-p/589922#M168797</link>
    <description>&lt;P&gt;i want to assign a random string to a variable. If say i have to pick a character from the below list. can you suggest me a code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"a","c","m","s","f","o"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Thu, 19 Sep 2019 05:52:16 GMT</pubDate>
    <dc:creator>VinitvictorCorr</dc:creator>
    <dc:date>2019-09-19T05:52:16Z</dc:date>
    <item>
      <title>Choosing random character value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choosing-random-character-value/m-p/589922#M168797</link>
      <description>&lt;P&gt;i want to assign a random string to a variable. If say i have to pick a character from the below list. can you suggest me a code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"a","c","m","s","f","o"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 05:52:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choosing-random-character-value/m-p/589922#M168797</guid>
      <dc:creator>VinitvictorCorr</dc:creator>
      <dc:date>2019-09-19T05:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: Choosing random character value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choosing-random-character-value/m-p/589923#M168798</link>
      <description>&lt;P&gt;Do something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   array _{6} $ ('a','c','m','s','f','o');
   idx=rand('integer', 1, dim(_));
   RandLetter=_[idx];

   put RandLetter=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Sep 2019 06:00:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choosing-random-character-value/m-p/589923#M168798</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-09-19T06:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: Choosing random character value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choosing-random-character-value/m-p/589924#M168799</link>
      <description>thanks again &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Thu, 19 Sep 2019 06:02:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choosing-random-character-value/m-p/589924#M168799</guid>
      <dc:creator>VinitvictorCorr</dc:creator>
      <dc:date>2019-09-19T06:02:54Z</dc:date>
    </item>
    <item>
      <title>Re: Choosing random character value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choosing-random-character-value/m-p/589925#M168800</link>
      <description>i tried rand before, but it said it wouldn't work on character values,but this is great&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Sep 2019 06:03:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choosing-random-character-value/m-p/589925#M168800</guid>
      <dc:creator>VinitvictorCorr</dc:creator>
      <dc:date>2019-09-19T06:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: Choosing random character value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choosing-random-character-value/m-p/589982#M168816</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289580"&gt;@VinitvictorCorr&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;i tried rand before, but it said it wouldn't work on character values,but this is great&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Alternative techniques to let RAND "work on character values" include&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;the &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n1tcjbeu8jft0dn1hy0xtg08g28d.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;CHAR function&lt;/A&gt; (for single characters):&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;RandLetter=char('acmsfo',rand('integer',6));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;the &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p0zkcvlqdqdnu6n16vv32uojnznj.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;CHOOSEC function&lt;/A&gt; (for strings of any lengths):&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;RandLetter=choosec(rand('integer',6),'a','c','m','s','f','o');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;the &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p0jshdjy2z9zdzn1h7k90u99lyq6.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;SCAN function&lt;/A&gt; (for strings of any lengths):&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;RandLetter=scan('a c m s f o',rand('integer',6));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Thu, 19 Sep 2019 10:56:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choosing-random-character-value/m-p/589982#M168816</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-09-19T10:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: Choosing random character value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choosing-random-character-value/m-p/590010#M168822</link>
      <description>&lt;P&gt;Sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp; &amp;nbsp;Really love your CHOOSEC. My oh my honestly didn't expect, While it's easy to acknowledge the charm of how your thought process works, I recall Guru &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp; effecting the use of such functions and many more to &lt;U&gt;super effect&lt;/U&gt; in his SAS-L posts. I wonder if SAS-L still exists, and if yes DN is even on it anymore. Anyways,&amp;nbsp; Just goes to &lt;STRONG&gt;prove, &lt;EM&gt;great minds think alike&lt;/EM&gt;&lt;/STRONG&gt; i.e you, king, PG, hashman etc are in a league of your own. Class act!&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 13:13:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choosing-random-character-value/m-p/590010#M168822</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-09-19T13:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Choosing random character value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choosing-random-character-value/m-p/590031#M168826</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;,&amp;nbsp;but I'm not sure what's so inventive about using those character functions with a random number argument. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding SAS-L: Since they started requiring a login even for read access (less than 6 years ago; at least my old links suddenly didn't work anymore, but led to a login screen) I haven't been there. But it was a valuable source of information for me in my earlier years (only reading, not posting). Luckily, a few of the SAS-L giants have joined the SAS Support Communities.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 14:08:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choosing-random-character-value/m-p/590031#M168826</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-09-19T14:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: Choosing random character value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choosing-random-character-value/m-p/590032#M168827</link>
      <description>&lt;P&gt;I meant, it's not about the inventive, it's just that not many would even think or search along the lines finding a function for a cause and would rather go with we/they know. I guess it's the presence of mind to look for what and where let alone how simple or complex that may be.&lt;/P&gt;
&lt;P&gt;I am also glad that some of the SAS-L are right here. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 14:16:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choosing-random-character-value/m-p/590032#M168827</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-09-19T14:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Choosing random character value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choosing-random-character-value/m-p/590041#M168832</link>
      <description>&lt;P&gt;And if for some reason you would like to have a random but not uniform chance of selection something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;idx=rand('table', 0.2, 0.4, 0.1, 0.05, 0.15, 0.1);
RandLetter=_[idx];
&lt;/PRE&gt;
&lt;P&gt;You need to know the number of elements selected from and the numbers represent the percentage of selecting that position. They must add to 1 or you will either get a n+1 possible response if the sum is less than 1 with the probability not included in the total or examine the documentation as the possibilities get a bit harder to explain quickly.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 14:36:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choosing-random-character-value/m-p/590041#M168832</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-09-19T14:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: Choosing random character value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choosing-random-character-value/m-p/590817#M169149</link>
      <description>wow,, thats awesome.. didnt know about these functions in sas.. Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Mon, 23 Sep 2019 03:57:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choosing-random-character-value/m-p/590817#M169149</guid>
      <dc:creator>VinitvictorCorr</dc:creator>
      <dc:date>2019-09-23T03:57:51Z</dc:date>
    </item>
  </channel>
</rss>

