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

I'm trying to concatenate two rows one that has standard format and one is italic but I'd like to retain the formatting of the columns so the first part of the text is standard and the second part is italic. As an example I've used the cars data set to illustrate.

 

data cars;
set sashelp.cars;
run;

    proc freq data=cars;
    table make*type/list out=c1;
    run;

 


ods escape char="~";
proc report data=c1 split='^' style=journal;


column make type final count;

 

define make /display left 'Make' style(column)=[width=10%] ;
define type /left display 'Type' style(column)=[width=10% font_style=italic];
   define final /computed left 'Make, ~S={font_style=italic}Type' style(column)=[width=10%] ;
define count/center display "M(SD) ^ or N(%)" style(column)=[width=10%];

 

compute final /character length=95;
   final=cat(trim(make),", ",left(trim(type)));
endcomp;

 

run;

 

I'd initially attached this to another thread but haven't gotten any responses so I figured it was best to ask a new question.  https://communities.sas.com/t5/ODS-and-Base-Reporting/Concatenate-Variables-in-proc-report/m-p/61581...

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  You've got the right idea about needing ODS ESCAPECHAR, but you're using it in the WRONG place. The data values will not automatically use italic from the TYPE column in the COMPUTE block for FINAL. The style in one cell is not going to impact the style in a computed . And ESCAPECHAR is one word (not 2 words as you show).

correct_escapechar.png

 

  It wasn't clear to me whether you wanted the HEADER to use 2 different styles or the HEADER and the DATA values. In this output. I did both the HEADER and the DATA/COLUMN values. I used red as the foreground for MAKE just to show how to apply a different style to the MAKE value too. And I switched to the current method for specifying the style formatting your method (~S=) is the original method, which may still work, but doesn't have the same capabilities for nesting as the current method.

 

Hope this helps,

cynthia

View solution in original post

2 REPLIES 2
Cynthia_sas
SAS Super FREQ

Hi:

  You've got the right idea about needing ODS ESCAPECHAR, but you're using it in the WRONG place. The data values will not automatically use italic from the TYPE column in the COMPUTE block for FINAL. The style in one cell is not going to impact the style in a computed . And ESCAPECHAR is one word (not 2 words as you show).

correct_escapechar.png

 

  It wasn't clear to me whether you wanted the HEADER to use 2 different styles or the HEADER and the DATA values. In this output. I did both the HEADER and the DATA/COLUMN values. I used red as the foreground for MAKE just to show how to apply a different style to the MAKE value too. And I switched to the current method for specifying the style formatting your method (~S=) is the original method, which may still work, but doesn't have the same capabilities for nesting as the current method.

 

Hope this helps,

cynthia

Rae_
Fluorite | Level 6

This is exactly what I needed!  Thanks Cynthia.  I only did it in the header to make the point because I couldn't get it to work in the cells.  I really appreciate the help!

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
  • 1335 views
  • 1 like
  • 2 in conversation