2014-11-03 204 views
0

這可以通過使用ODS來實現,但我有一個約束,我不應該使用ODS,因爲我使用的是Listing。我需要生成RTF報告,其中包含超級和下標文本。以下是我所指的使用ODS的示例代碼。在沒有ODS的SAS中打印上標或下標

ods rtf file='temp.rtf'; 
ods escapechar='^'; 

proc print data=sashelp.class; 
    title 'this value is superscripted ^{super 2} '; 
    title2 'this value is subscripted ^{sub 2} '; 
run; 

ods rtf close; 

我想在Proc報告標題或腳註中打印上標或下標文本。

+0

等等,我真的不明白這一點,現在我再讀一遍。 LISTING與RTF不同,它們彼此無關。你能否更詳細地解釋約束條件(如果可能的話,逐字回答,特別是如果這是一個家庭作業問題)? – Joe 2014-11-03 21:41:48

回答

0

我不相信這是可能的ODS上市。 (任何告訴你不使用ODS的人都是錯誤的,因爲與所有其他目標一樣,列表是ODS輸出目標,但我假設你的意思是除了ODS列表之外不能使用其他任何內容,或者使用某些ODS ESCAPECHAR等常見ODS技巧)。

但是,ODS列表在播放字體方面沒有多少可用的空間。您可以把超2:

ods listing; 
proc print data=sashelp.class; 
title "Fun²"; 
run; 
ods listing close; 

通過逐字輸入的字符到文本中,但是這並不適用於所有可能的標,我不認爲有標等效於上市字體。

您可以在線查找字符列表,例如in this paper。您可以用'##'x來插入它們,其中##是該字符的2位十六進制代碼,或者鍵入它們(例如,對於²,則使用alt + 0178或使用字符映射查找它們;請確保使用正確的字體。)

1

愚蠢的約束需要同樣愚蠢的解決方案 - 誰需要ODS escapechar當你可以硬編碼rtf control sequences for subscripts and superscripts

x 'cd c:\temp'; 
/*Produce initial rtf without superscripts/subscripts*/ 
ods rtf file='temp.rtf'; 

proc print data=sashelp.class; 
    title 'this value is superscripted 2'; 
    title2 'this value is subscripted 2'; 
run; 

ods rtf close; 

/*Add them in manually as per .rtf file format specification*/ 
data _null_; 
    infile "c:\temp\temp.rtf" lrecl = 32767; 
    file "c:\temp\want.rtf"; 
    input; 
    length rtf $32767; 
    rtf = _infile_; 
    rtf = tranwrd(rtf, 'this value is superscripted 2', 'this value is superscripted \super 2 \nosupersub'); 
    rtf = tranwrd(rtf, 'this value is subscripted 2', 'this value is subscripted \sub 2 \nosupersub'); 
    put rtf; 
run; 
+0

我完全被這個問題弄糊塗了,但是我喜歡這個答案,不管它是否真的解決了這個問題! – Joe 2014-11-03 21:42:42