<?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: Issue in masking in sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Issue-in-masking-in-sas/m-p/686780#M208449</link>
    <description>Each column will have only one word? No Van der Bergens?&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 25 Sep 2020 17:05:27 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-09-25T17:05:27Z</dc:date>
    <item>
      <title>Issue in masking in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-in-masking-in-sas/m-p/686752#M208444</link>
      <description>&lt;P&gt;I need to do masking of my data in order to hide it from the target audience. Please find below existing table that I have right now. There are 3 columns in that table.&lt;/P&gt;&lt;PRE class="lang-sql s-code-block hljs"&gt;&lt;CODE&gt;SNO FIRSTNAME LASTNAME 
1   JAYVADAN  DARJI
2   KAPIL     CHAUDHARY&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In the desired output, I want 4 columns with masking done as below. MASKED_NAME column would be an addition column the desired output.&lt;/P&gt;&lt;P&gt;The desired output that I want&lt;/P&gt;&lt;PRE class="lang-sql s-code-block hljs"&gt;&lt;CODE&gt;SNO FIRSTNAME LASTNAME   MASKED_NAME 
1   JAYVADAN  DARJI      JXXXXXXN DXXXI
2   KAPIL     CHAUDHARY  KXXXL CXXXXXXXY&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks a lot in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2020 16:21:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-in-masking-in-sas/m-p/686752#M208444</guid>
      <dc:creator>Sanchit1</dc:creator>
      <dc:date>2020-09-25T16:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: Issue in masking in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-in-masking-in-sas/m-p/686764#M208448</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/333659"&gt;@Sanchit1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I need to do masking of my data in order to hide it from the target audience. Please find below existing table that I have right now. There are 3 columns in that table.&lt;/P&gt;
&lt;PRE class="lang-sql s-code-block hljs"&gt;&lt;CODE&gt;SNO FIRSTNAME LASTNAME 
1   JAYVADAN  DARJI
2   KAPIL     CHAUDHARY&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In the desired output, I want 4 columns with masking done as below. MASKED_NAME column would be an addition column the desired output.&lt;/P&gt;
&lt;P&gt;The desired output that I want&lt;/P&gt;
&lt;PRE class="lang-sql s-code-block hljs"&gt;&lt;CODE&gt;SNO FIRSTNAME LASTNAME   MASKED_NAME 
1   JAYVADAN  DARJI      JXXXXXXN DXXXI
2   KAPIL     CHAUDHARY  KXXXL CXXXXXXXY&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks a lot in advance.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;One way:&lt;/P&gt;
&lt;PRE&gt;data example;
  input SNO FIRSTNAME :$10. LASTNAME :$10.;
  length masked_name $ 25;
  masked_name=catx(' ',cats(substr(firstname,1,1),repeat('X',length(firstname)-3),substr(firstname,length(firstname))),
                       cats(substr(lastname,1,1),repeat('X',length(lastname)-3),substr(lastname,length(lastname)))
                  );
datalines;
1   JAYVADAN  DARJI
2   KAPIL     CHAUDHARY
;
&lt;/PRE&gt;
&lt;P&gt;Set the length of masked name to the longest expected value, remember to include the space between the names.&lt;/P&gt;
&lt;P&gt;The Repeat function creates a string of the characters repeated the number of times in the second parameter. SUBSTR extracts parts of a string, LENGTH returns the number of characters in a string ignoring trailing blanks, CATS contcatenates strings stripping blanks, CATX inserts a specified character between strings when concatenated&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2020 16:55:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-in-masking-in-sas/m-p/686764#M208448</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-25T16:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: Issue in masking in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-in-masking-in-sas/m-p/686780#M208449</link>
      <description>Each column will have only one word? No Van der Bergens?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Sep 2020 17:05:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-in-masking-in-sas/m-p/686780#M208449</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-09-25T17:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Issue in masking in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-in-masking-in-sas/m-p/686794#M208451</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;Here is an approach that uses&amp;nbsp; Regular Expression&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length sno 4 FIRSTNAME $20 LASTNAME $20;
input SNO FIRSTNAME $ LASTNAME $;
datalines; 
1 JAYVADAN DARJI
2 KAPIL CHAUDHARY
;
run;

data want(drop=m_:);
	set have;
	length m_FIRSTNAME m_LASTNAME masked_name $60;
	m_FIRSTNAME=cat(SUBSTR(FIRSTNAME,1,1),SUBSTR(prxchange('s/(\w)(.*?)(?=\w)/x/', -1, FIRSTNAME),2));
	m_LASTNAME=cat(SUBSTR(LASTNAME,1,1),SUBSTR(prxchange('s/(\w)(.*?)(?=\w)/x/', -1, LASTNAME),2));
	masked_name=catx(' ',m_FIRSTNAME,m_LASTNAME);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Ahmed&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2020 17:48:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-in-masking-in-sas/m-p/686794#M208451</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2020-09-25T17:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: Issue in masking in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-in-masking-in-sas/m-p/686809#M208453</link>
      <description>&lt;P&gt;You can replace the center substring of each 'word' with X's by using SUBSTR on the LEFT SIDE of the equals sign.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;data have; 
length firstname lastname $50;
input firstname &amp;amp; lastname &amp;amp;;
datalines;
JAYVADAN  DARJI
KAPIL     CHAUDHARY
BOBBY JOE  MCALLISTER 
KAPIL     A CHAUDHARY JR
;

data want;
  set have;

  length masked_name $100;

  _name = catx(' ', firstname, lastname);

  do _n_ = 1 to countw(_name);
    _word = scan(_name, _n_);

    select (length(_word));
      when (1) _word = '*';
      when (2) _word = '**';
      otherwise substr(_word,2,length(_word)-2) = repeat('*', length(_word));
    end;

    masked_name = catx(' ', masked_name, _word);
  end;  

  drop _:;
run;&lt;/PRE&gt;
&lt;P&gt;Output data&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RichardADeVenezia_0-1601060699140.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/49813iF1E9EAF9D4B6757A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RichardADeVenezia_0-1601060699140.png" alt="RichardADeVenezia_0-1601060699140.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2020 19:07:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-in-masking-in-sas/m-p/686809#M208453</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-09-25T19:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: Issue in masking in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-in-masking-in-sas/m-p/686911#M208491</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
length firstname lastname $50;
input firstname &amp;amp; lastname &amp;amp;;
datalines;
JAYVADAN  DARJI
KAPIL     CHAUDHARY
BOBBY JOE  MCALLISTER 
KAPIL     A CHAUDHARY JR
;

data want;
  set have;
  new_firstname=firstname; 
  new_lastname=lastname;

  n=length(new_firstname);
  do i=1 to n;
    if i ne 1 and i ne n then substr(new_firstname,i,1)='X';
  end;

  n=length(new_lastname);
  do i=1 to n;
    if i ne 1 and i ne n then substr(new_lastname,i,1)='X';
  end;
  drop i n;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 26 Sep 2020 11:46:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-in-masking-in-sas/m-p/686911#M208491</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-09-26T11:46:20Z</dc:date>
    </item>
  </channel>
</rss>

