<?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: How to translate values? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-translate-values/m-p/926511#M364599</link>
    <description>&lt;P&gt;If you run PROC CONTENTS and PROC PRINT on work.new, you'll see that your first step has not created the dataset you are hoping for.&amp;nbsp; Perhaps try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
    input fname : $8.  ssn : $9.;
    cards;
John 123456789
daniel 851295790
steve 473967594
becky 203954769
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you can move on to debugging the second step.&amp;nbsp; You don't need to loop over each character.&amp;nbsp; You can just call TRANSLATE once, like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set sashelp.class ;
  name2=translate(upcase(name),"!@#$%^&amp;amp;*()*^%$#@!%^&amp;amp;()^%$#","ABCDEFGHIJKLMNOPQRSTUVWXYZ") ;
  put name= name2= ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 30 Apr 2024 18:05:38 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2024-04-30T18:05:38Z</dc:date>
    <item>
      <title>How to translate values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-translate-values/m-p/926508#M364597</link>
      <description>&lt;P&gt;Hey Guys, I am trying to encrypt the ssn and fname variables using the below code; The ssn seems to be working, but not the fname. Any suggestions or tweaks for making this work?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;%let ssn_enc=Y*Z$%^WX&amp;amp;(;
%let ssn_pass=1029384756;

%let name_enc=!@#$%^&amp;amp;*()*^%$#@!%^&amp;amp;()^%$#;
%let name_pass=ABCDEFGHIJKLMNOPQRSTUVWXYZ;

data new;
    input fname $8. ssn $9;
    cards;
John 123456789
daniel 851295790
steve 473967594
becky 203954769
;
run;

data new1;
    set new;
    length encrypt_ssn $9. encrypt_fname $10.; /* Length of encrypted variables */

    /* Encrypt SSN */
    encrypt_ssn = '';
    do i=1 to 9;
        encrypt_ssn = encrypt_ssn || translate(strip(substr(ssn,i,1)), symget('ssn_pass'), symget('ssn_enc'));
    end;

    /* Encrypt fname */
    encrypt_fname = '';
    do i=1 to 8; 
        encrypt_fname = encrypt_fname || translate(strip(substr(fname,i,1)), symget('name_pass'), symget('name_enc'));
    end;

run;
&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Apr 2024 17:53:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-translate-values/m-p/926508#M364597</guid>
      <dc:creator>prad001</dc:creator>
      <dc:date>2024-04-30T17:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to translate values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-translate-values/m-p/926511#M364599</link>
      <description>&lt;P&gt;If you run PROC CONTENTS and PROC PRINT on work.new, you'll see that your first step has not created the dataset you are hoping for.&amp;nbsp; Perhaps try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
    input fname : $8.  ssn : $9.;
    cards;
John 123456789
daniel 851295790
steve 473967594
becky 203954769
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you can move on to debugging the second step.&amp;nbsp; You don't need to loop over each character.&amp;nbsp; You can just call TRANSLATE once, like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set sashelp.class ;
  name2=translate(upcase(name),"!@#$%^&amp;amp;*()*^%$#@!%^&amp;amp;()^%$#","ABCDEFGHIJKLMNOPQRSTUVWXYZ") ;
  put name= name2= ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Apr 2024 18:05:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-translate-values/m-p/926511#M364599</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-04-30T18:05:38Z</dc:date>
    </item>
  </channel>
</rss>

