<?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 ID Generator in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Random-ID-Generator/m-p/670251#M201168</link>
    <description>&lt;P&gt;Below should do what you're asking for.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let chars=123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz#@;
%let special=#@;
%let id_len=6;

data want(drop=_:);
  length id_out $ &amp;amp;id_len;
  do _i=1 to &amp;amp;id_len;
    _idx=rand('integer',1,%length(&amp;amp;chars));
    id_out=cats(id_out,substr("&amp;amp;chars",_idx,1));
  end;

  do until(_check=3);
    _check=0;
    /* digit 1 to 9? */
    if prxmatch('/\d/',id_out)&amp;lt;1 then 
      do;
        _idx=rand('integer',1,&amp;amp;id_len);
        _idy=rand('integer',rank('1'),rank('9'));
        substr(id_out, _idx, 1)=byte(_idy);
      end;
    else _check=sum(_check,1);
    /* upper case letter? */
    if prxmatch('/[A-Z]/',id_out)&amp;lt;1 then 
      do;
        _idx=rand('integer',1,&amp;amp;id_len);
        _idy=rand('integer',rank('A'),rank('Z'));
        substr(id_out, _idx, 1)=byte(_idy);
      end;
    else _check=sum(_check,1);
    /* special char? */
    if prxmatch("/[&amp;amp;special]/",id_out)&amp;lt;1 then 
      do;
        _idx=rand('integer',1,&amp;amp;id_len);
        _idy=rand('integer',1,%length(&amp;amp;special));
        substr(id_out, _idx, 1)=substr("&amp;amp;special",_idy,1);
      end;
    else _check=sum(_check,1);
  end;

  output;
  stop;
run;

proc print;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 18 Jul 2020 04:02:08 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2020-07-18T04:02:08Z</dc:date>
    <item>
      <title>Random ID Generator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-ID-Generator/m-p/670247#M201165</link>
      <description>&lt;P&gt;Hello SAS friends, I am new to SAS and I am still learning. I am in need of a program that generates a random ID. I found a script on this forum and made a few changes and it works, but it is not quite what I need. I need this script to force the random generating ID to Always use at least 1 upper case letter, 1 number and 1 special character (# or&amp;nbsp;@). Is this possible? Here is the code I am using.&lt;/P&gt;&lt;PRE&gt;data temp (keep=id_out);

  allowed="123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz#@";

  num_ids=1;

  idlen=8;

  array done{100} $200.;

  length my_id $6;

  num_allowed=length(strip(allowed));

  i=1;

  do until (i=num_ids+1);

    do j=1 to 6;

      temp=ceil((num_allowed * rand("uniform")));

      substr(my_id,j,1)=substr(allowed,temp,1);

    end;

    if whichc(my_id,of done{*})=0 then do;

      done{i}=my_id;

      i=i+1;

      id_out=my_id;

      output;

    end;

  end;

run;&lt;/PRE&gt;&lt;P&gt;Any help would be great!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 02:51:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-ID-Generator/m-p/670247#M201165</guid>
      <dc:creator>amt11189</dc:creator>
      <dc:date>2020-07-18T02:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: Random ID Generator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-ID-Generator/m-p/670249#M201166</link>
      <description>I would first select in order 1 random uppercase, 1 random number, 1 random special character, 5 random any characters as array elements e.g. c1-c8. Then randomly sort the array and assign the id by concatenating c1-c8 after randomization. There are many ways to do this in SAS. This approach guarantees your requirements (1 each of the given categories and 8 total).&lt;BR /&gt;</description>
      <pubDate>Sat, 18 Jul 2020 03:22:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-ID-Generator/m-p/670249#M201166</guid>
      <dc:creator>qatman28</dc:creator>
      <dc:date>2020-07-18T03:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: Random ID Generator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-ID-Generator/m-p/670251#M201168</link>
      <description>&lt;P&gt;Below should do what you're asking for.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let chars=123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz#@;
%let special=#@;
%let id_len=6;

data want(drop=_:);
  length id_out $ &amp;amp;id_len;
  do _i=1 to &amp;amp;id_len;
    _idx=rand('integer',1,%length(&amp;amp;chars));
    id_out=cats(id_out,substr("&amp;amp;chars",_idx,1));
  end;

  do until(_check=3);
    _check=0;
    /* digit 1 to 9? */
    if prxmatch('/\d/',id_out)&amp;lt;1 then 
      do;
        _idx=rand('integer',1,&amp;amp;id_len);
        _idy=rand('integer',rank('1'),rank('9'));
        substr(id_out, _idx, 1)=byte(_idy);
      end;
    else _check=sum(_check,1);
    /* upper case letter? */
    if prxmatch('/[A-Z]/',id_out)&amp;lt;1 then 
      do;
        _idx=rand('integer',1,&amp;amp;id_len);
        _idy=rand('integer',rank('A'),rank('Z'));
        substr(id_out, _idx, 1)=byte(_idy);
      end;
    else _check=sum(_check,1);
    /* special char? */
    if prxmatch("/[&amp;amp;special]/",id_out)&amp;lt;1 then 
      do;
        _idx=rand('integer',1,&amp;amp;id_len);
        _idy=rand('integer',1,%length(&amp;amp;special));
        substr(id_out, _idx, 1)=substr("&amp;amp;special",_idy,1);
      end;
    else _check=sum(_check,1);
  end;

  output;
  stop;
run;

proc print;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 04:02:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-ID-Generator/m-p/670251#M201168</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-07-18T04:02:08Z</dc:date>
    </item>
  </channel>
</rss>

