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

Hi all,

 

I have an rtf table with three levels of output indent values that need to look like this (2 spaces at each indent):

ATC Level 1 /

  ATC Level 2 /
    Generic Drug Name

 

 

One level of output looks like this.  I would like that last line of output to continue with the indent but it is wrapping back to the left.  

 

SENSORY ORGANS

  OPHTHALMOLOGICALS

    ASCORBIC ACID;CUPRIC OXIDE;DL-ALPHA TOCOPHERYL ACETATE; XANTOFYL; ZEAXANTHIN;ZINC OXIDE

 

 

my code looks like this:

 

if ord=1 then do;
name =strip(ATC01TXT);
end;
else if ord=2 then do;
name ='  ' || strip(ATC02TXT);
end;
else if ord=3 then do;
name ='    ' || strip(generic);
end;

 

Is there something I can add in the datastep to continue the indent when the text wraps?

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  When I use some "helper" variables to indicate which level to indent, the wrapping works as you explain. Here's the fake data I made, with some "helper" variables called TYPVAR and ORDVAR:

fake_data_to_wrap.png

Indenting "spaces" doesn't really apply to a proportional font, so I used the LEFTMARGIN style override to force the indenting, based on the value of ORDVAR within each TYPVAR value.

 

results_using_leftmargin.png

I set the overall width of the column to 3in to ensure that the longest line (line 3) would wrap, and then set the LEFTMARGIN attribute based on the value of ORDVAR.

 

  Since you didn't say what destination you were interested in, I used RTF for this example. I used PROC REPORT to product a report table, since indenting in a dataset doesn't make sense.

 

  Here's the full code:

data fakedata;
  length typvar 8 ordvar 8 lineinfo $500;
  infile datalines dlm=',' dsd;
  input typvar ordvar lineinfo $;
return;
datalines4;
1,1,"SENSORY ORGANS"
1,2,"OPHTHALMOLOGICALS"
1,3,"ASCORBIC ACID;CUPRIC OXIDE;DL-ALPHA TOCOPHERYL ACETATE; XANTOFYL; ZEAXANTHIN;ZINC OXIDE"
2,1,"First Line"
2,2,"Second Line"
2,3,"Third Line is very long; and needs to be indented too; and now that's all."
;;;;
run;

ods rtf file='c:\temp\showindent.rtf';
proc report data=fakedata;
   column typvar ordvar lineinfo;
   define typvar / group noprint;
   define ordvar / order noprint;
   define lineinfo / 'Information'
          style(column)={width=3in};
   compute lineinfo;
      if ordvar =1 then do;
	    call define(_col_,'style','style={fontweight=bold leftmargin=0in}');
	  end;
	  else if ordvar=2 then do;
	    call define(_col_,'style','style={fontweight=bold leftmargin=.125in}');
	  end;
	  else if ordvar = 3 then do;
	    call define(_col_,'style','style={fontweight=bold leftmargin=.25in}');
	  end;
   endcomp;
run;
ods rtf close;




Hope this helps,

Cynthia

View solution in original post

2 REPLIES 2
ballardw
Super User

What ods destination are you sending output to? You may have to include destination specific codes as part of the values or table building code.

Cynthia_sas
SAS Super FREQ

Hi:

  When I use some "helper" variables to indicate which level to indent, the wrapping works as you explain. Here's the fake data I made, with some "helper" variables called TYPVAR and ORDVAR:

fake_data_to_wrap.png

Indenting "spaces" doesn't really apply to a proportional font, so I used the LEFTMARGIN style override to force the indenting, based on the value of ORDVAR within each TYPVAR value.

 

results_using_leftmargin.png

I set the overall width of the column to 3in to ensure that the longest line (line 3) would wrap, and then set the LEFTMARGIN attribute based on the value of ORDVAR.

 

  Since you didn't say what destination you were interested in, I used RTF for this example. I used PROC REPORT to product a report table, since indenting in a dataset doesn't make sense.

 

  Here's the full code:

data fakedata;
  length typvar 8 ordvar 8 lineinfo $500;
  infile datalines dlm=',' dsd;
  input typvar ordvar lineinfo $;
return;
datalines4;
1,1,"SENSORY ORGANS"
1,2,"OPHTHALMOLOGICALS"
1,3,"ASCORBIC ACID;CUPRIC OXIDE;DL-ALPHA TOCOPHERYL ACETATE; XANTOFYL; ZEAXANTHIN;ZINC OXIDE"
2,1,"First Line"
2,2,"Second Line"
2,3,"Third Line is very long; and needs to be indented too; and now that's all."
;;;;
run;

ods rtf file='c:\temp\showindent.rtf';
proc report data=fakedata;
   column typvar ordvar lineinfo;
   define typvar / group noprint;
   define ordvar / order noprint;
   define lineinfo / 'Information'
          style(column)={width=3in};
   compute lineinfo;
      if ordvar =1 then do;
	    call define(_col_,'style','style={fontweight=bold leftmargin=0in}');
	  end;
	  else if ordvar=2 then do;
	    call define(_col_,'style','style={fontweight=bold leftmargin=.125in}');
	  end;
	  else if ordvar = 3 then do;
	    call define(_col_,'style','style={fontweight=bold leftmargin=.25in}');
	  end;
   endcomp;
run;
ods rtf close;




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
  • 2 replies
  • 3477 views
  • 2 likes
  • 3 in conversation