BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Excelsius
Obsidian | Level 7

I have this syntax:

 

  if variable = "IL-1B" then xLabel='IL-1ß';
  if variable = "TNFa" then xLabel='TNFα';

Beta values are displayed fine; however, for some reason alpha values still end up as "a" instead of alpha. Is there a quick way around this? I tried the unicode entry, but that didn't work either: 'TNF ^{unicode 0251}'

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Works fine in SAS University Edition. Possibly, you just need to change your encoding to UTF-8.

 

Art, CEO, AnalystFinder.com

 

View solution in original post

13 REPLIES 13
art297
Opal | Level 21

Works fine in SAS University Edition. Possibly, you just need to change your encoding to UTF-8.

 

Art, CEO, AnalystFinder.com

 

Excelsius
Obsidian | Level 7

That didn't work. Under unicode, "TNF ^{unicode 0251}" prints out as and the Greek characters are replaced by a question mark (by design probably). Also, the letter size of the Log increased. I had to revert back. Followed instructions here to change to unicode: http://support.sas.com/kb/51/586.html

 

Any other ideas? I'm using SAS 9.4 14.3 M5 desktop edition.

art297
Opal | Level 21

After following those instructions did you close and then reopen SAS before testing the code?

 

Art, CEO, AnalystFinder.com

 

ballardw
Super User

@Excelsius wrote:

That didn't work. Under unicode, "TNF ^{unicode 0251}" prints out as and the Greek characters are replaced by a question mark (by design probably). Also, the letter size of the Log increased. I had to revert back. Followed instructions here to change to unicode: http://support.sas.com/kb/51/586.html

 

Any other ideas? I'm using SAS 9.4 14.3 M5 desktop edition.


First time I've seen anyone much concerned about letter size (font height?) in the log. Is there a particular reason for that?

Excelsius
Obsidian | Level 7
Has to do with the efficiency of reviewing the log. With a very large increase in font size requires a lot of scrolling to view the logs. Either way, the main issue is that unicode didn't write the Greek characters, or I would have used it.
ChrisNZ
Tourmaline | Level 20

Can you post the log and output when you run this please?

 

data T; xLabel='TNFα'; run;

proc options group=languagecontrol; run;

proc print data=T; run;

proc contents data=T; run;
Excelsius
Obsidian | Level 7

Here is the log:

952  data T; xLabel='TNFa'; run;

NOTE: The data set WORK.T has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


953
954  proc options group=languagecontrol; run;

    SAS (r) Proprietary Software Release 9.4  TS1M5


Group=LANGUAGECONTROL
 DATESTYLE=MDY     Specifies the sequence of month, day, and
                   year when ANYDTDTE, ANYDTDTM, or ANYDTTME
                   informat data is ambiguous.
 DFLANG=ENGLISH    Specifies the language for international
                   date informats and formats.
 DSCAS             Runs the DATA step on the CAS server.
 EXTENDOBSCOUNTER=YES
                   Specifies whether to extend the maximum
                   number of observations in a new SAS data
                   file.
 LOCALEDATA=SASLOCALE
                   Specifies the location of the locale
                   database.
 NOLOGLANGCHG      Disables changing the language of the SAS
                   log when the LOCALE= option is changed.
 NOLOGLANGENG      Write SAS log messages based on the values
                   of the LOGLANGCHG, LSWLANG=, and LOCALE=
                   options when SAS started.
 LSWLANG=LOCALE    Specifies the language for SAS log and ODS
                   messages when the LOCALE= option is set
                   after SAS starts.
 MAPEBCDICTOASCII= Specifies the transcoding table that is used
                   to convert characters from ASCII to EBCDIC
                   and EBCDIC to ASCII.
 NONLDECSEPARATOR  Disables formatting of numeric output using
                   the decimal separator for the locale.
 NOODSLANGCHG      Disables changing the language of the SAS
                   message text in ODS output when the LOCALE
                   option is set after start up.
 PAPERSIZE=LETTER  Specifies the paper size to use for printing.
 RSASIOTRANSERROR  Displays a transcoding error when illegal
                   values are read from a remote application.
 TIMEZONE=         Specifies a time zone.
 TRANTAB=(lat1lat1,lat1lat1,wlt1_ucs,wlt1_lcs,wlt1_ccl,,,)
                   Specifies the translation table catalog
                   entries.
 URLENCODING=SESSION
                   Specifies whether the argument to the
                   URLENCODE function and to the URLDECODE
                   function is interpreted using the SAS
                   session encoding or UTF-8 encoding.
 NODBCS            Disables double-byte character sets.
 DBCSLANG=NONE     Specifies a double-byte character set
                   language.
 DBCSTYPE=NONE     Specifies the encoding method to use for a
                   double-byte character set.
 ENCODING=WLATIN1  Specifies the default character-set encoding
                   for the SAS session.
 LOCALE=EN_US      Specifies a set of attributes in a SAS
                   session that reflect the language, local
                   conventions, and culture for a geographical
                   region.
 NONLSCOMPATMODE   Encodes data using the SAS session encoding.
NOTE: PROCEDURE OPTIONS used (Total process time):
      real time           0.04 seconds
      cpu time            0.03 seconds


955
956  proc print data=T; run;

NOTE: There were 1 observations read from the data set WORK.T.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


957
958  proc contents data=T; run;

NOTE: PROCEDURE CONTENTS used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


 

Output attached.

 

art297
Opal | Level 21

Encoding was set to WLatin1 not UTF-8

 

Art, CEO, AnalystFinder.com

 

Excelsius
Obsidian | Level 7

Thanks Art. Per my post above, setting encoding to UTF-8 did not resolve the issue. So of course I reverted back. Am I missing something?

 

I now switched back to UTF before running your code. The Output (attached) is still the same - no alpha. Reminder that under wlatin, I do get the beta printed. Just not the alpha. I'm not clear why.

NOTE: Copyright (c) 2016 by SAS Institute Inc., Cary, NC, USA.
NOTE: SAS (r) Proprietary Software 9.4 (TS1M5 MBCS3170)
NOTE: This session is executing on the X64_10PRO  platform.



NOTE: Updated analytical products:

      SAS/STAT 14.3
      SAS/ETS 14.3
      SAS/OR 14.3
      SAS/IML 14.3
      SAS/QC 14.3

NOTE: Additional host information:

 X64_10PRO WIN 10.0.16299  Workstation

NOTE: SAS initialization used:
      real time           1.19 seconds
      cpu time            1.03 seconds

1    data T; xLabel='TNFa'; run;

NOTE: The data set WORK.T has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


2
3    proc options group=languagecontrol; run;

    SAS (r) Proprietary Software Release 9.4  TS1M5


Group=LANGUAGECONTROL
 DATESTYLE=MDY     Specifies the sequence of month, day, and
                   year when ANYDTDTE, ANYDTDTM, or ANYDTTME
                   informat data is ambiguous.
 DFLANG=ENGLISH    Specifies the language for international
                   date informats and formats.
 DSCAS             Runs the DATA step on the CAS server.
 EXTENDOBSCOUNTER=YES
                   Specifies whether to extend the maximum
                   number of observations in a new SAS data
                   file.
 LOCALEDATA=SASLOCALE
                   Specifies the location of the locale
                   database.
 LOGLANGCHG        Enables changing the language of the SAS log
                   when the LOCALE= option is changed.
 NOLOGLANGENG      Write SAS log messages based on the values
                   of the LOGLANGCHG, LSWLANG=, and LOCALE=
                   options when SAS started.
 LSWLANG=LOCALE    Specifies the language for SAS log and ODS
                   messages when the LOCALE= option is set
                   after SAS starts.
 MAPEBCDICTOASCII= Specifies the transcoding table that is used
                   to convert characters from ASCII to EBCDIC
                   and EBCDIC to ASCII.
 NONLDECSEPARATOR  Disables formatting of numeric output using
                   the decimal separator for the locale.
 ODSLANGCHG        Enables the language of the SAS message text
                   in ODS output to change when the LOCALE
                   option is set after start up.
 PAPERSIZE=A4      Specifies the paper size to use for printing.
 RSASIOTRANSERROR  Displays a transcoding error when illegal
                   values are read from a remote application.
 TIMEZONE=         Specifies a time zone.
 TRANTAB=          Specifies the translation table catalog
                   entries.
 URLENCODING=SESSION
                   Specifies whether the argument to the
                   URLENCODE function and to the URLDECODE
                   function is interpreted using the SAS
                   session encoding or UTF-8 encoding.
 DBCS              Enables double-byte character sets for
                   encoding East Asian languages.
 DBCSLANG=UNKNOWN  Specifies a double-byte character set
                   language.
 DBCSTYPE=UTF8     Specifies the encoding method to use for a
                   double-byte character set.
 ENCODING=UTF-8    Specifies the default character-set encoding
                   for the SAS session.
 LOCALE=EN_US      Specifies a set of attributes in a SAS
                   session that reflect the language, local
                   conventions, and culture for a geographical
                   region.
 NONLSCOMPATMODE   Encodes data using the SAS session encoding.
NOTE: PROCEDURE OPTIONS used (Total process time):
      real time           0.06 seconds
      cpu time            0.06 seconds


4
5    proc print data=T; run;
NOTE: Writing HTML Body file: sashtml.htm

NOTE: There were 1 observations read from the data set WORK.T.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.37 seconds
      cpu time            0.38 seconds


6
7    proc contents data=T; run;

NOTE: PROCEDURE CONTENTS used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds


8
9    proc print data=t;
10   run;

NOTE: There were 1 observations read from the data set WORK.T.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds
art297
Opal | Level 21

Unless I'm not reading your code correctly, you didn't ask for an alpha to be in your code. You appear to have run:

 

data T;
 xLabel='TNFa';
run;

I'd like to see the results after you run (with utf-8 encoding):

 

data t;
  xLabel='IL-1ß';
  yLabel='TNFα';
run;
proc print;
run;

Art, CEO, AnalystFinder.com

 

ChrisNZ
Tourmaline | Level 20

As @art297 said, WLATIN1 is used by your SAS session to process data, and to create the data set where the data is stored.

 

The WLATIN1 character set does not include Greek letters. See here,

Excelsius
Obsidian | Level 7

Never mind. For whatever reason, running unicode the second time worked (yes, I did open and close SAS). As another issue, the sample code I copied from here didn't write alpha, but just 'a.'

 

Thanks for the tip about the unicode. Since it's not the default, is there a reason not to be in unicode mode?

 

I also found a way to change the log font: Tools->Options->Font.

ChrisNZ
Tourmaline | Level 20

> Since it's not the default, is there a reason not to be in unicode mode?

 None, except most historical data is written in ASCII, and therefore there will be a performance penalty reading ASCII tables in a UTF8 SAS session.

 

I didn't notice differences in data set size, even when storing double-byte values like Russian characters (and I can't explain why. Why oh why?).

 

Also, once you allow Unicode data in the data sets, a warning in the log will inform that these characters are lost whenever non-ASCII characters are retrieved from a non-Unicode SAS session.

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of 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
  • 13 replies
  • 6477 views
  • 0 likes
  • 4 in conversation