Hi:
Yes, but (generally)I prefer to assemble my whole line like this using a temporary variable -- especially if I want/need to use a PUT to expand a value:
[pre]
compute ...;
length myline $150;
myline = 'The product is: '||put(product,$pfmt.);
lgvar = length(myline);
line myline $varying. lgvar;
endcomp;
[/pre]
And, there are a few other caveats --
1) PROC REPORT works from LEFT to RIGHT...so, for example if you have this COLUMN statement:
[pre]
column var1 var2 var3 var4;
[/pre]
PROC REPORT has no visibility of VAR4 when it is putting VAR1 on the report. This can affect a COMPUTE block ,such as when you are calculating a new report item. For example, if you wanted to compute the total of VAR3 and VAR4 into an item called TOT, then your COLUMN statement and COMPUTE block would have to be:
[pre]
column var1 var2 var3 var4 TOT;
... more code...
compute TOT;
TOT = sum(var3,var4);
endcomp;
[/pre]
but, you could NOT have:
[pre]
column var1 var2 TOT var3 var4 ;
... more code...
compute TOT;
TOT = sum(var3,var4);
endcomp;
[/pre]
That above assignment statement would be the one needed if VAR3 and VAR4 were both DISPLAY usage. IF they had been SUM usage, then the correct assignment statement needed would change to the "compound" name
variable.statistic:
TOT=sum(var3.sum, var4.sum);
2) when you are dealing with GROUP or ORDER items, and you want to use a value at the break (such as you want to to with PRODUCT, you have to realize that by default, PROC REPORT suppresses the repetitive values of GROUP or ORDER items. So, using the above data, if you wanted to show values for ALLOBS and SPECBRK at the "AFTER" for the break processing, you would have to create temporary variables to hold the values -- because at the AFTER location, the value for a GROUP or ORDER variable is blank. If you wanted to show values for ALLOBS and SPECBRK at the "BEFORE" location for break processing, you'd be able to use use the value of the variable because on the first report row for a break variable, the value is available.
So, you may have to "grab" the value of product and "save it" for later use in your line statement. This paper is a good resource on PROC REPORT and how to avoid some of the common "beginner" mistakes that folks frequently make with PROC REPORT:
http://support.sas.com/resources/papers/proceedings10/133-2010.pdf
cynthia
[pre]
ods listing close;
ods html file='c:\temp\left_right.html' style=sasweb;
proc report data=work.final nowd;
title '1) Using a group or order value at a break';
column allobs specbrk ordvar age amin amean amed amax;
define allobs / order;
define specbrk / order;
define ordvar / order;
define age / display f=3.;
define amin / display f=6.2;
define amean / display f=6.2;
define amed / display f=6.2;
define amax / display f=6.2;
compute before allobs;
length hold_ao $3;
hold_ao = allobs;
endcomp;
compute before specbrk/ style={font_weight=bold just=l};
length hold_sp 3.;
hold_sp = specbrk;
line 'The current value of specbrk at BEFORE is ' specbrk 3.;
endcomp;
compute after specbrk / style={font_weight=bold just=l};
line 'The current value of specbrk at AFTER is ' specbrk 3.;
line 'The current value of specbrk(held) is ' hold_sp 3.;
endcomp;
compute after/ style={font_weight=bold just=l};
line 'The value of allobs at AFTER is: ' allobs $3.;
line 'The value of allobs(held) is: ' hold_ao $3.;
endcomp;
run;
ods html close;
[/pre]