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'));
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.
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.
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.
Thanks @LeonidBatkhan
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.