<?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: Mask values retaining the special characters at the same postion in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Mask-values-retaining-the-special-characters-at-the-same-postion/m-p/595017#M171101</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Name $ 1-21 ID $ 23-27;
datalines;
Alice                 09876
(Mr).Hellen 'O' Brain 12345
Hau &amp;amp; Pin             09876
;

data want;
    set have;
	old_name=name;
	name=compress(name,,'s'); 
    stid=cats('STUDENT', ID);
n=0;
do i=1 to max(length(name),length(stid));
 t=char(name,i);
 if anyalpha(t) or missing(t) then do;
   n+1; substr(name,i,1)=char(stid,n);
 end;
end;
drop n i t;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 09 Oct 2019 12:03:38 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2019-10-09T12:03:38Z</dc:date>
    <item>
      <title>Mask values retaining the special characters at the same postion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mask-values-retaining-the-special-characters-at-the-same-postion/m-p/594995#M171092</link>
      <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need help in masking a variable by retaining the special characters at the same position in the masked value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Name :&lt;/P&gt;&lt;P&gt;Alice&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Mr).Hellen 'O' Brain&lt;/P&gt;&lt;P&gt;Hau &amp;amp; Pin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expected Result after masking:&lt;/P&gt;&lt;P&gt;Name:&lt;/P&gt;&lt;P&gt;STUDENT09876&lt;/P&gt;&lt;P&gt;(ST).UDENT1'2'345&lt;/P&gt;&lt;P&gt;STU&amp;amp;DENT09876&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;all names are to masked as STUDENT followed by their student id.&lt;/P&gt;&lt;P&gt;if the names have special characters , the special character is to be placed at the same position as in the original string. even if it has multiple special characters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help for the multiple special character scenario is appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in Advance !!&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 09:49:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mask-values-retaining-the-special-characters-at-the-same-postion/m-p/594995#M171092</guid>
      <dc:creator>somu19tec</dc:creator>
      <dc:date>2019-10-09T09:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: Mask values retaining the special characters at the same postion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mask-values-retaining-the-special-characters-at-the-same-postion/m-p/595001#M171094</link>
      <description>&lt;P&gt;So the Student ID is given in another variable or?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 10:16:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mask-values-retaining-the-special-characters-at-the-same-postion/m-p/595001#M171094</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-09T10:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: Mask values retaining the special characters at the same postion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mask-values-retaining-the-special-characters-at-the-same-postion/m-p/595009#M171097</link>
      <description>Yes , student ID is another variable which we can concatenate.&lt;BR /&gt;</description>
      <pubDate>Wed, 09 Oct 2019 11:14:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mask-values-retaining-the-special-characters-at-the-same-postion/m-p/595009#M171097</guid>
      <dc:creator>somu19tec</dc:creator>
      <dc:date>2019-10-09T11:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: Mask values retaining the special characters at the same postion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mask-values-retaining-the-special-characters-at-the-same-postion/m-p/595010#M171098</link>
      <description>&lt;P&gt;How about this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Name $ 1-21 ID $ 23-27;
datalines;
Alice                 09876
(Mr).Hellen 'O' Brain 12345
Hau &amp;amp; Pin             09876
;

data want(keep=Stid);
    set have;
    stid=cats('STUDENT', ID);
    do pos=1 to length(compress(Name));
        c=char(compress(Name), pos);
        if prxmatch('/[^A-Z 0-9]/i',c) then do;
            if pos=1 then stid=cats(c, stid);
            else stid = cat(substr(stid, 1, pos-1), c, substr(stid, pos));
        end;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;stid
STUDENT09876
(ST).UDENT1'2'345
STU&amp;amp;DENT09876&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Oct 2019 11:16:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mask-values-retaining-the-special-characters-at-the-same-postion/m-p/595010#M171098</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-09T11:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: Mask values retaining the special characters at the same postion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mask-values-retaining-the-special-characters-at-the-same-postion/m-p/595017#M171101</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Name $ 1-21 ID $ 23-27;
datalines;
Alice                 09876
(Mr).Hellen 'O' Brain 12345
Hau &amp;amp; Pin             09876
;

data want;
    set have;
	old_name=name;
	name=compress(name,,'s'); 
    stid=cats('STUDENT', ID);
n=0;
do i=1 to max(length(name),length(stid));
 t=char(name,i);
 if anyalpha(t) or missing(t) then do;
   n+1; substr(name,i,1)=char(stid,n);
 end;
end;
drop n i t;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Oct 2019 12:03:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mask-values-retaining-the-special-characters-at-the-same-postion/m-p/595017#M171101</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-10-09T12:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: Mask values retaining the special characters at the same postion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mask-values-retaining-the-special-characters-at-the-same-postion/m-p/595105#M171141</link>
      <description>&lt;P&gt;Since you have a student Id I really question the utility of&amp;nbsp;this. It sort of smells like a programming class assignment.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 15:27:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mask-values-retaining-the-special-characters-at-the-same-postion/m-p/595105#M171141</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-10-09T15:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: Mask values retaining the special characters at the same postion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mask-values-retaining-the-special-characters-at-the-same-postion/m-p/595233#M171201</link>
      <description>Hi Ballardw,&lt;BR /&gt;It's not an assignment , we are working on a migration project for one of&lt;BR /&gt;our client which is a school , so inorder to mask the production data , we&lt;BR /&gt;are doing this.&lt;BR /&gt;</description>
      <pubDate>Thu, 10 Oct 2019 01:57:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mask-values-retaining-the-special-characters-at-the-same-postion/m-p/595233#M171201</guid>
      <dc:creator>somu19tec</dc:creator>
      <dc:date>2019-10-10T01:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: Mask values retaining the special characters at the same postion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mask-values-retaining-the-special-characters-at-the-same-postion/m-p/595236#M171202</link>
      <description>&lt;P&gt;Thanks Ksharp, this is also the solution i was looking for. but&amp;nbsp; i am not able to mark this as a solution as i already marked another reply as solution.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2019 02:14:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mask-values-retaining-the-special-characters-at-the-same-postion/m-p/595236#M171202</guid>
      <dc:creator>somu19tec</dc:creator>
      <dc:date>2019-10-10T02:14:36Z</dc:date>
    </item>
  </channel>
</rss>

