BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Shmuel
Garnet | Level 18

I'm trying to replace a month name from some Hebrew encoding to UTF given as a string literal by using transtrn() function but the string was not replaced:

73         data _null_;
 74           txt = '3139363920F8E1EEE8F4F1203035'x;
 75           t1 = scan(txt,2,' ');
 76           t2 = 'september';
 77         
 78           txt_new = transtrn(txt,t2,t1);
 79           put txt_new=;
 80         run;
 
 txt_new=1969 ������ 05

it should be:

   "1969 september 05"

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @Shmuel,

 

Change the order of the second and third argument and apply the TRIM function:

txt_new = transtrn(txt,trim(t1),t2);

View solution in original post

3 REPLIES 3
FreelanceReinh
Jade | Level 19

Hi @Shmuel,

 

Change the order of the second and third argument and apply the TRIM function:

txt_new = transtrn(txt,trim(t1),t2);
Shmuel
Garnet | Level 18

Thanks, both functions result as expecterd: trim(t1) as strip(t1)

Kurt_Bremser
Super User

What @FreelanceReinh said, and heed Maxim 46:

data _null_;
  txt = '3139363920F8E1EEE8F4F1203035'x;
  t1 = scan(txt,2,' ');
  t2 = 'september';

  txt_new = transtrn(txt,strip(t1),t2);
  put txt_new=;
run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1202 views
  • 1 like
  • 3 in conversation