- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I'm using SAS 9.4 and it seems to convert tab to space in a text string automatically. Is there any way to output tab instead of space to rtf. Thank you in advance!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It is very likely that your source code has had the tabs turned to spaces when saving the file.
Also please describe what you are attempting to accomplish here. Tab characters are not of a standard length and in an RTF document the locations of results would be based on an individuals settings for their default document. So inserting a fixed number of characters to align results is not reliable.
Since your are looking to send to RTF look at the escapechar function RAW to insert a raw RTF tab using #{Raw \tab} for a single tab or \tab\tab for two tabs.
data work.rtf; length cr1 - cr2 $64; cr1 = "#S={leftmargin= 0.5cm}#{Raw \tab\tab}< 80%"; cr2 = "8 (10.0%)"; output; cr1 = "#S={leftmargin= 0.5cm}80% <=#{raw \tab}< 90%"; cr2 = "72 (90.0%)"; output; run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi:
How do you know that you have tabs in the data. SAS procedures will not produce tabs. Are you using PROC PRINT or PROC REPORT on data with tabs -- do you use the RTF control string \tab (I think) or the Excel '09'x in hexadecimal?
Without any idea of your data or your code or your RTF settings for ODS, it's hard to make any constructive suggestions.
Cynthia
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello Cynthia,
I am trying to output something like this for example, with [tab] is actual tab space.
I want to output the same tab space as tab in MS Words without being convert to spaces.
Thank you for considering!
data rtf;
length cr1 - cr2 $64;
cr1 = "#S={leftmargin= 0.5cm}[tab][tab]< 80%";
cr2 = "8 (10.0%)";
output;
cr1 = "#S={leftmargin= 0.5cm}80% <=[tab]< 90%";
cr2 = "72 (90.0%)";
output;
run;
ods listing close;
ods results off;
ods escapechar='#' ;
options orientation = portrait nodate nonumber;
ods rtf file = "C:\users\&sysuserid.\Desktop\sample.rtf" style = journal;
proc report data=rtf nowindows split='@' missing;
column cr1 cr2;
define cr1 / "column1" style(column)={asis=on cellwidth= 40%};
define cr2 / "column2" style(column)={asis=on cellwidth= 20%};
run;
ods listing;
ods results on;
ods rtf close;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It is very likely that your source code has had the tabs turned to spaces when saving the file.
Also please describe what you are attempting to accomplish here. Tab characters are not of a standard length and in an RTF document the locations of results would be based on an individuals settings for their default document. So inserting a fixed number of characters to align results is not reliable.
Since your are looking to send to RTF look at the escapechar function RAW to insert a raw RTF tab using #{Raw \tab} for a single tab or \tab\tab for two tabs.
data work.rtf; length cr1 - cr2 $64; cr1 = "#S={leftmargin= 0.5cm}#{Raw \tab\tab}< 80%"; cr2 = "8 (10.0%)"; output; cr1 = "#S={leftmargin= 0.5cm}80% <=#{raw \tab}< 90%"; cr2 = "72 (90.0%)"; output; run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Are you just asking how to get the actual tab ('09'x) character into your data variables?
data rtf;
length cr1 - cr2 $64;
cr1 = "#S={leftmargin= 0.5cm}"||'0909'x||"< 80%";
cr2 = "8 (10.0%)";
output;
cr1 = "#S={leftmargin= 0.5cm}80% <="||'09'x||"< 90%";
cr2 = "72 (90.0%)";
output;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi:
Well, if you right justify the data values, you don't really need tab or left margin at all:
But if you WANT to insert the RTF control for tab, it is \tab as shown below (without right justification, so you could see the impact of using the left margin:
I wonder whether you want a demographic report such as shown on page 9 or 17 of this paper: https://support.sas.com/resources/papers/proceedings/pdfs/sgf2008/173-2008.pdf ? If so, these reports were done without using RTF tabs.
Hope this helps,
Cynthia