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.

 

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