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

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!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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;

 

View solution in original post

5 REPLIES 5
Cynthia_sas
SAS Super FREQ

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

hlnquynh
Obsidian | Level 7

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;

ballardw
Super User

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;

 

Tom
Super User Tom
Super User

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;
Cynthia_sas
SAS Super FREQ

Hi:

  Well, if you right justify the data values, you don't really need tab or left margin at all:

notab.png

 

  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:

use_tab_rtf.png

 

  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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 2776 views
  • 3 likes
  • 4 in conversation