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

Hi folks,

 

Is there any simple way to convert a string to octal notation? For example:

 

origina string: "mó test"
expected string: "m\363 test"

I tried to use KPROPDATA function, but it returns in UTF or latin. I can't find how to define octal notation.

 

Regards, 

 

 

 

KPROPDATA("&diretorio.",'UESC','utf8'));

 

1 ACCEPTED SOLUTION

Accepted Solutions
LeonidBatkhan
Lapis Lazuli | Level 10

You can use $OCTALw. Format to do just that. For example, the following code:

 

data _null_;
   c = 'ó';
   c_oct = put(c, $octal.);
   put c= / c_oct=;
run;

will produce:

c=ó
c_oct=363

 

Hope this helps.

 

View solution in original post

4 REPLIES 4
LeonidBatkhan
Lapis Lazuli | Level 10

Hi MariaD,

Do you want to convert to octal the whole string (as formulated in your question) or just a specific character (as shown in your example)? Please clarify.

 
MariaD
Barite | Level 11

Hi @LeonidBatkhan ,

 

Thanks, just the specific character.

 

Regards, 

LeonidBatkhan
Lapis Lazuli | Level 10

You can use $OCTALw. Format to do just that. For example, the following code:

 

data _null_;
   c = 'ó';
   c_oct = put(c, $octal.);
   put c= / c_oct=;
run;

will produce:

c=ó
c_oct=363

 

Hope this helps.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 4 replies
  • 1296 views
  • 1 like
  • 2 in conversation