Examples


Example 1: Modifying a Key Map

Procedure features:

  • GKEYMAP options:

    • DATA =

    • KEYMAP

    • NAME =

    • OUT=

Other features:

  • DATA step

  • GOPTIONS procedure

  • GOPTIONS statement

  • LIBNAME statement

  • SORT procedure

Sample library member: GKYMODIF

click to expand

This example shows how to change multiple characters in an existing key map. It assumes that the national characters and & pound ; are not on your keyboard, so you want to create a key map that provides them.

To provide the character, this example s key map converts the @ character into the SAS/GRAPH internal encoding for ( B8 x). Whenever the @ character is typed in text that is displayed with a software font, the character is drawn instead. In this case, the replacement character uses the text position that would have been used by the typed character.

Note: Once you have modified your key map so that @ is mapped to , you can no longer generate @ in a software font from your keyboard when the key map is in effect.

To provide the character, which is not on the keyboard or in the ICE table, this example s key map converts the asterisk (*) into the SAS/GRAPH internal encoding for the accent character D5 x (a tilde). In this case, when the character * is typed, the resulting tilde does not take up a text position but is backspaced and used as an accent over the character preceding it in the text. To create the character, therefore, the text must contain the two characters a*.

Note: The example updates the current key map rather than creating a new key map so that all of the other character mapping in the key map remains in effect.

Assign the libref and set the graphics environment. LIBNAME associates the libref GFONT0 with the location of the SAS data library where your device maps and key maps are stored.

 libname gfont0 '  SAS-data-library  ';  goptions reset=global gunit=pct border cback=white           colors=(black blue green red)           ftext=swiss ftitle=swissb htext=6; 

Determine the name of the current key map. The SAS log in Output 34.1 shows that the keymap name is DEFAULT.

 proc goptions     option=keymap;  run; 
Output 34.1: Log from GOPTIONS Procedure
start example
 SAS/GRAPH software options and parameters                    (executing in DMS Process environment)  KEYMAP=DEFAULT               Input character map for hardware and software                               text 
end example
 

Copy the DEFAULT key map to a temporary SAS data set. NAME= specifies the DEFAULT key map as input to the procedure. OUT= specifies the data set TEMP, which is created from the specified key map.

 proc gkeymap name=default     out=temp;  run; 

Create data set NEW. NEW will be used to create the key map for the character conversions. Values for the FROM variable are the keyboard characters to be converted. Values for the TO variable are hexadecimal codes from the SAS ICE table. OUTPUT is required to write a separate observation for each character to be mapped.

 data new;     from='@';     to='b8'x;     output;     from='*';     to='d5'x;     output;  run; 

Sort data set NEW and update data set TEMP with the mapping information. The data set NEW must be sorted by the FROM variable before its observations can be used to update data set TEMP.

 proc sort data=new;     by from;  data temp;     update temp new;     by from;  run; 

Create a new key map from the modified data set. NAME= assigns a name to the new key map. DATA= specifies the data set TEMP as input to the procedure. KEYMAP specifies that the map being generated is a key map (the default).

 proc gkeymap name=mykeymap               data=temp               keymap;  run; 

Specify the new key map in a GOPTIONS statement. KEYMAP= specifies the name of the new key map so that when the characters @ and a* are specified in TITLE statements, the characters and are displayed in the output.

 goptions keymap=mykeymap; 

Print two titles with the special characters. The character @ is typed where the character should print, and the character * is typed after the character it will accent.

 title1 'Kaiserstra@e';  title2 'Sa*o Paulo';  footnote j=r 'GKYMODIF ';  proc gslide;  run;  quit;.  ' 



SAS.GRAPH 9.1 Reference, Volumes I and II
SAS.GRAPH 9.1 Reference, Volumes I and II
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 342

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net