The SAS Output Delivery System and reporting techniques

Proc Report - how to display a group variable only once

Reply
Contributor Ivy
Contributor
Posts: 73

Proc Report - how to display a group variable only once

[ Edited ]

Hello,

 

I am tyring to output the data, with one variable treated as group variable , using following codes, but somehow the group option does not work.  

 

"define var_label/ display "Demographic and Clinical characteristics " spacing=0 group flow order;" 

 

var_label 

Gender, n(%)

Gender, n(%)

 

I would like to show one Gender, n(%) , but somehow, it still showes two.

 

proc REPORT data= _table_1 nowd headline missing nocenter spacing=0 ls=256 ps=1000 split='^' style(header)=[font_weight=bold just=center] style(column)=[just=center];
column vord rord var_label var_level _2007 _2008 _2009 _2010 _2011 _2012 _2013 _2014 Total ;
define vord/noprint order;
define rord/noprint order;
define var_label/ display "Demographic and Clinical characteristics " spacing=0 group flow order;
define var_level/display "" spacing=0 order;

define _2007/display "Index_year_2007 (N=&gp_2007)" width=18;
define _2008/display "Index_year_2008 (N=&gp_2008)" width=18;
define _2009/display "Index_year_2009 (N=&gp_2009)" width=18;
define _2010/display "Index_year_2010 (N=&gp_2010)" width=18;
define _2011/display "Index_year_2011 (N=&gp_2011)" width=18;
define _2012/display "Index_year_2012 (N=&gp_2012)" width=18;
define _2013/display "Index_year_2013 (N=&gp_2013)" width=18;
define _2014/display "Index_year_2014 (N=&gp_2014)" width=18;
define Total/display "Index_year_total (N=&gp_Total)" width=18;

title "Table 1. Baseline demographic and clinic characteristics ";
run;
quit;

 

Thank you,

 

Ivy 

Grand Advisor
Posts: 16,304

Re: Proc Report - how to display a group variable only once

You have var_label listed twice - two define statements. 

 

Contributor Ivy
Contributor
Posts: 73

Re: Proc Report - how to display a group variable only once

Thank you, Reeza.
I double check it, I just list once. Var_label, var_level . Two different names. Did I miss something ? Thank you.
Grand Advisor
Posts: 16,304

Re: Proc Report - how to display a group variable only once

You're correct, I misread it. 

 

I'm not familiar enough with Proc Report to help beyond this, especially without sample input data. I'm sure someone else will help. 

It may help if you post an image of what you're getting and an example of what you want as well. 

Good Luck.

Contributor Ivy
Contributor
Posts: 73

Re: Proc Report - how to display a group variable only once

[ Edited ]

Examples data;

Var_label                                 var_level                     ..........................
Gender, n(%)                          Male
Gender, n(%)                         Female

 

Output table I want:

 

Var_label          Var_level ........................

Gender, n(%)    Male

                         Female 



Thanks.

Grand Advisor
Posts: 9,699

Re: Proc Report - how to display a group variable only once

You define Var_label as both group and order. Try having it as just order.

Can't test without data but those sort of conflict and often the last option mentioned controls when conflicting.

Contributor Ivy
Contributor
Posts: 73

Re: Proc Report - how to display a group variable only once

I use group, order separately, but somehow, it still dose not work :-(

demog Index_year_2007 (N=429) Index_year_2008 (N=585)
Age at index N 429 585
Age at index Mean (SD) 62.2 (11.7) 60.8 (11.6)
Age at index Median(Min - Max) 61 (28-89) 60 (29-90)
Gender, n(%) Female 107 (24.9) 151 (25.8)
Gender, n(%) Male 322 (75.1) 434 (74.2)
Geographic region, n(%) South 149 (34.7) 219 (37.4)
Geographic region, n(%) North Central 148 (34.5) 191 (32.6)
Geographic region, n(%) Northeast 43 (10) 55 (9.4)
Geographic region, n(%) West 56 (13.1) 80 (13.7)
Geographic region, n(%) Unknown 33 (7.7) 40 (6.8)
Grand Advisor
Posts: 9,315

Re: Proc Report - how to display a group variable only once

You'd better post some data to let us test your code and reproduce the problem.
And try compute block:



 compute var_label;
   if var_label ne lag(var_label) then call missing(var_label);
endcomp;

SAS Super FREQ
Posts: 8,642

Re: Proc Report - how to display a group variable only once

I do not think the LAG or DIF functions work in PROC REPORT, the OP has other problems with her code (she has DISPLAY, GROUP and ORDER in one DEFINE statement) which is more problematic. She needs to fix her other issues with the code before introducing COMPUTE blocks.

cynthia
Grand Advisor
Posts: 9,315

Re: Proc Report - how to display a group variable only once

That is reason why I ask OP to post data .
We all just guessing.
We don't know if GROUP could work or COMPUTE could work .


Post a Question
Discussion Stats
  • 9 replies
  • 740 views
  • 0 likes
  • 5 in conversation