PROC REPORT DATA = work.BEH_AGG_5 ;
column RAC Groupe GENERATION production ANNEE_AMO, CRD_GEN_MENS_MEAN ;
define RAC / group ;
define Groupe / group ;
define GENERATION / group ;
define production / group ;
define ANNEE_AMO / across ;
define CRD_GEN_MENS_MEAN / '' f=12.2 ;
title ;
RUN ;
Hello,
By launch this code, the indicators CRD_GEN_MENS_MEAN are correctly aligned in one line correspoinf to a combination of group variables. the problem is that the value of RAC is displayed only once (first row).
I would like to display it one each row. so I specified display as "define RAC / group display ; "
and then the RAC value is effectively repeated but now , the indicators CRD_GEN_MENS_MEAN values are not aligned anymore.
thanks a lot in adcance for your help
thanks for your quick respons. I found the solution insisde proc report by using a compute like this :
COMPUTE RAC ;
IF RAC NE ' ' then hold=RAC ;
IF RAC EQ ' ' then RAC=hold ;
ENDCOMP;
then in the clumn RAC, the first value is repeated
PROC REPORT DATA = work.BEH_AGG_5 nowd ;
column RAC Groupe GENERATION production ANNEE_AMO, CRD_GEN_MENS_MEAN ;
define RAC / group ;
define Groupe / group ;
define GENERATION / group ;
define production / group ;
define ANNEE_AMO / across ;
define CRD_GEN_MENS_MEAN / '' f=12.2 ;
title ;
RUN ;
hello,
I would like to get a report with the column "year" transposed and with the variable group values repeated.
with the enclosed code, I succeed to get the indicators values aligned on the same line (this is intended). but the value of group variable is only once displayed (first row).
by specifying "display" like this "define RAC / group display ;" the values are repeated (not sorted) but indicators are no aligned anymore.
thanks a lot for your help
thanks for your quick respons. I found the solution insisde proc report by using a compute like this :
COMPUTE RAC ;
IF RAC NE ' ' then hold=RAC ;
IF RAC EQ ' ' then RAC=hold ;
ENDCOMP;
then in the clumn RAC, the first value is repeated
Since the value for GROUP value is only displayed once, you have to put it aside.
For this you need some logic in Proc REPORT, see sample below. However if you just need that data to be then exported, see the Proc SQL and Proc TRANSPOSE code below.
proc report data=sashelp.cars;
column type displayType driveTrain origin, msrp _dummy;
define type / group noprint;
define driveTrain / group;
define displayType / computed ;
define origin / across;
define msrp / analysis;
define _dummy / computed noprint;
compute displayType / char length=32;
endcomp;
compute _dummy / char length=32;
if type ne " " then do;
tempName = type;
end;
_dummy = tempName;
displayType = tempName;
endcomp;
run;
proc sql;
create table cars_aggr as
select
type, driveTrain, origin, sum(msrp) as msrp_sum
from
sashelp.cars
group by
type, driveTrain, origin
order by
type, driveTrain, origin
;
quit;
proc transpose
data=cars_aggr
out=cars_trsp
;
by type driveTrain;
var msrp_sum;
id origin;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.