KCVT Function

Converts data from one type of encoding data to another encoding data.
Category: Character


KCVT(text, intype, outtype, <options,…> )

Required Arguments

specifies the character variable to be converted.
specifies the encoding of the data. The encoding of the text must match the input data's encoding. For valid values, see SBCS, DBCS, and Unicode Encoding Values for Transcoding Data.
ASCIIANY and EBCIDICANY are invalid encoding values.
specifies the encoding to be converted into character data. For valid values seeSBCS, DBCS, and Unicode Encoding Values for Transcoding Data.
ASCIIANY and EBCIDICANY are invalid encoding values.
specifies character data options. Here are the available options:
NOSOSI | NOSHIFT No shift code or Hankaku characters.
INPLACE Replaces character data by conversion. The INPLACE option is specified to secure the same location between different hosts whose lengths of character data are not identical. For example, the INPLACE option converts data from the host which requires Shift-Codes, into the other host, which does not require shift codes. Truncation occurs when the length of the character data that is converted into outtype for Shift-Codes is longer than the length that is specified in intype.
KANA Includes Hankaku katakana characters in columns of character data.
UPCASE Converts 2-byte alphabet to uppercase characters.
LOWCASE Converts 2-byte alphabet to lowercase characters.
KATA2HIRA Converts katakana data to Hiragana.
HIRA2KATA Converts Hiragana data to katakana.


See Internationalization Compatibility for SAS String Functions for restrictions and more information.
The KCVT function converts SBCS, DBCS, and MBCS character strings into encoding data. For example, the KCVT function can convert: ASCII code data to UCS2 encoding data, Greek code data to UTF-8, and Japanese SJIS code data to another Japanese code data. You can specify the following types for Intype and Outtype options: UCS2, UCS2L, UCS2B, and UTF8. To enable the DBCS mode, specify the following SAS options in the configuration file or in the command line.
  • DBCS
  • DBCSLANG Japanese or Korean or Chinese or Taiwanese
  • DBCSTYPE dbcstype value


The following code converts IBM PC codes into DEC codes for the external text file specified as my-input-file, and writes in OUTDD.
 data _null_;
    infile 'my-input-file';
    file outdd noprint;
    input @1 text $char80.;
    text = kcvt(text, 'pcibm', 'dec');
    put @1 text $char80.;