In Data, Titles And/Or Footnotes Using Character and Hexadecimal
Total Page:16
File Type:pdf, Size:1020Kb
PharmaSUG2010 - Paper CC19 Embedded Special Characters Kiran Karidi, Mahipal Vanam, and Sridhar Dodlapati ABSTRACT When the report generated from the clinical trial data requires to show lot of information in titles and column headers than they can accommodate, then Statisticians / Medical writers use special characters such as subscription, superscription, Greek letters, mathematical symbols, and custom-designed symbols etc to flag, and the complete corresponding information is provided in the footnotes for that flag. There are various techniques available to embed the special characters in the clinical study reports and they will be discussed in this paper. INTRODUCTION Quite often, in clinical trial data analysis reports, we may have to flag the data, titles, footnotes, column headers and graphs (axis labels and/or on the graphical area) with special characters, and give explanation for them in the footnotes. Rationale behind that is, when there is not sufficient space available in the target areas, the need arises to put a flag there and elaborate it later in the footnote. The reason to use the special symbols or characters for this purpose is to distinguish them with other characters and to make them more prominent. SPECIAL CHARACTERS There are different definitions for special characters depending on the encoding system (ASCII, EBCDIC & Unicode are most popular encoding systems), but in common usage, a character is considered as a special character, if that is not readily available on a standard computer keyboard. A special character can either display something or control the display of the characters that follow. Display character examples are: the trademark sign ‘™’, the registered trademark sign ‘®’ and degree ‘°’ as in degree Cels ius (°C) etc. Control character examples are: new l ine/line feed, new page/form feed, horizontal tab, vertical tab etc. However, for the purpose of flagging, it is obvious that we use the display special characters only. The regular SAS output files are plain text files; and we need special techniques to incorporate the special characters into them. Irrespective of the technique we use to embed the special character in the SAS output, they all follow the same process. First they are written to the code through editor, then during the execution time they are processed and finally they will carry out the specific function they were supposed to do i.e. display or control the display. Also, there are some other factors that influence the outcome, which include SAS version, operating system, system settings, font etc. APPROACHES TO EMBED THE SPECIAL CHARACTERS Approach 1: Directly pasting the special character into the SAS code Even though the special characters are not available on the keyboard, we can put them directly in the SAS code by using the Character map utility provided by Windows Operating system. Go to start ► Programs ► Accessories ► System tools ► Character map. By default, Character map will have 'Arial' font as default. Depending on your need change the font from the drop down menu. For example default Character map looks like: 1 Choose the character you want, click on Select ► Copy. Then you can now directly paste this into the SAS windows editor in the required location in the SAS code. Pros: • Very simple method (choose, copy and paste). • No additional encoding or translation needed during SAS execution. Cons: • Only available in Windows operating system. • Location path for this utility might be different in different windows versions. • SAS windows editor may not support all characters in the utility for a particular font chosen. Characters that are not supported will be translated as a question mark (?) during the paste operation. • From the utility, font same as the default font used to viewing the output file needs to be chosen and that too only if available. Approach 2: Using 4 digit Unicode This method is similar to the first approach in terms that character map utility is used to choose the character required. The only difference is, instead of manually copying the character into the SAS code, get the 4 digit unicode for that character and use it in the SAS code as follows: %macro specchar(n=, symbol=); %global &symbol; data _null_; char=input(& n. , $UCS2B4. ); call symput( "&symbol." ,trim(left(char))); run; %put symbol=&&&symbol..; %mend ; %specchar (n= '00AE'x , symbol=registered_trademark); Output from SAS log: symbol=® Pros: • Unlike first approach, this approach works even if editor does not support certain characters. Cons: • Depends on Unicode the SAS format “$UCS2B4.” supports • Certain symbols encoded will cause text display truncation when used to display as rows in the body of the output. This is due to a bug in SAS 9.2. Other target areas such as titles, footnotes, column headers etc will work fine. Approach 3: Using SAS ODS escape character and the Unicode for the special character required 3a: For all Output destinations: SAS 9.2: ods html file ="sample.htm" ; ods escapechar= '^' ; proc print data =sashelp.class( obs =3) label ; label weight= "Weight ^{unicode 03B1}" ; footnote "^{unicode 03B1}Actual Weight may be collected weight ^{unicode 2267} 2 lbs" ; run ; 2 ods _all_ close ; Pros: Easy to use and supports all kinds of output destinations (HTML, RTF, PDF etc.) . Cons: Not reliable across output destinations. 3b: For RTF output destination using ODS RTF and RTF in-line formatting. SAS 8 code: ods rtf file ="sample.rtf" ; ods escapechar= '^' ; proc print data =sashelp.class( obs =3) label ; title1 'this value is superscripted ^{super 2} ' ; title2 'this value is subscripted ^{sub 2} ' ; run ; ods _all_ close ; SAS 9.2 code: ods rtf file ="sample.rtf" ; ods escapechar= '^' ; proc print data =sashelp.class( obs =3) label ; title1 'this value is superscripted ^\super 2 ' ; title2 'this value is subscripted ^\sub 2 ' ; run ; ods _all_ close ; 3 Pros: Many options to customize the special character display using the RTF pass through capability in version 9. Cons: This functionality is limited to RTF outputs. Approach 4: Using byte function One of the most popular ways of doing this is by using the BYTE function in SAS. BYTE(n), where n specifies an integer that represents a specific ASCII or EBCDIC character. The value of n can range from 0 to 255. If the BYTE function returns a value to a variable that has not yet been assigned a length, by default the variable is assigned a length of 1. For EBCDIC collating sequences, n is between 0 and 255. For ASCII collating sequences, the characters that correspond to values between 0 and 127 represent the standard character set. Other ASCII characters that correspond to values between 128 and 255 are available on certain ASCII operating environments, but the information those characters represent varies with the operating environment. Because Windows is an ASCII system, the BYTE function returns the nth character in the ASCII collating sequence. The value of n can range from 0 to 255. In IBM mainframe operating systems and some non-IBM platforms as well, where the EBCDIC encoding system is in effect, the BYTE function return the corresponding EBCDIC character. There are two approaches to get the special character by using the BYTE function: 4a. Direct use of BYTE function. 4b. Creating a macro variable using BYTE function, and then use the macro variable. 4a) DIRECT USE OF BYTE FUNCTION: This method is useful if a character need to be used at only one place or few places. proc print data =sashelp.class( obs =3); title1 "this value is subscripted %sysfunc(byte(178))" ; title2 'this value is subscripted ^{sub 2} ' ; run ; 4b) CREATING A MACRO VARIABLE USING BYTE FUNCTION, AND THEN USE THE MACRO VARIABLE: This method is useful if the same character need to be used in many places. %let special_char= %SYSFUNC (BYTE(n)); 4 Above created macro variable special_char can be used anywhere in the SAS code. To get the complete symbols list in your environment submit the following code, the decimal value and its corresponding character will be displayed in SAS log. data _null_ ; do i= 0 to 255 ; special_char=byte(i); put i + 10 special_char; end ; run ; Partial output from SAS log: REFERENCES http://support.sas.com/documentation/ http://support.sas.com/documentation/cdl/en/hostwin/61924/HTML/default/win-func-byte.htm Shiqun (Stan) Li, Minimax; Creating Special Symbols in SAS® Graphs. www.lexjansen.com/pharmasug/2008/cc/cc28.pdf Dennis Gianneschi; General Methods to Use Special Characters. http://www.wuss.org/proceedings08/08WUSS%20Proceedings/papers/cod/cod07.pdf CONTACT INFORMATION Your comments and questions are valued and encouraged. Contact the author at: Kiran Karidi ([email protected], [email protected]) Mahipal Vanam ([email protected], [email protected]) Sridhar Dodlapati ([email protected], [email protected]) SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. Other brand and product names are trademarks of their respective companies. 5 .