BookmarkSubscribeRSS Feed
Tom
Super User Tom
Super User

@sasuser92 wrote:

I am on Windows and get this:

LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

 


So you need to scrub your SAS datasets of any characters that do not fit into codepage 1252 (also known as WLATIN1 or LATIN1).

data want;
  set have;
*----------------------------------------------------------------------------;
* Convert any UTF-8 character not in LATIN1 codepage to HTML encoded strings ;
*----------------------------------------------------------------------------;
  array _character_ _character_;
  do over _character_;
    do until(_n_=0);
      _n_=kverify(_character_,collate(0,127)||kcvt(collate(128,255),'latin1','utf-8'));
      if _n_ then _character_=tranwrd(_character_,ksubstr(_character_,_n_,1)
                  ,htmlencode(ksubstr(_character_,_n_,1),'7bit'))
      ;
    end;
  end;
run;

Note you might have to make your character variables longer.

You might also need to do something about characters in variable labels.

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
  • 15 replies
  • 5240 views
  • 3 likes
  • 6 in conversation