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 / |
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?
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:
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.
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
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.
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:
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.
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.