BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Nasser_DRMCP
Lapis Lazuli | Level 10
	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

1 ACCEPTED SOLUTION

Accepted Solutions
Nasser_DRMCP
Lapis Lazuli | Level 10

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

 

View solution in original post

3 REPLIES 3
Nasser_DRMCP
Lapis Lazuli | Level 10

 

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

Nasser_DRMCP
Lapis Lazuli | Level 10

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

 

BrunoMueller
SAS Super FREQ

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

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