How to get SAS program code for encoding?

How can I find out the global SAS encoding option programmatically? I can run proc options and it will give me an answer, but I need to do this from the code.

I hope to get an answer to the line “take a look at the macro & sysencoding”, but this may be too much to hope for. I would prefer to avoid fragile things like writing to an external file and re-parsing.

+6
character-encoding sas
source share
2 answers

You can use the GETOPTION function in Base SAS:

 data _null_; val=GETOPTION('encoding'); put val=; run; 

On my system, this gives a log output

 5 data _null_; 6 val=GETOPTION('encoding'); 7 put val=; 8 run; val=LATIN1 

In SCL (SAS component language) you can use the OPTGETC and OPTGETN functions. See the manual for your specific SAS version for more information.

+7
source share

In SAS 9.2 &sysencoding you get the same thing as getoption('encoding') , although the case is different (it is described briefly here ).

 157 %put &sysencoding; wlatin1 158 159 data _null_; 160 val=GETOPTION('encoding'); 161 put val=; 162 run; val=WLATIN1 
+3
source share

All Articles