Good morning,
I have a proc report, with a display of tabs according to my "group by" in ods excel.
I take the example of the class table.
If I have 2 sheet according to my "group by" "Sex" (F and M) I want to display all of my columns if I am in the (M) sheet.
and if I am in sheet (F) I want to hide a few columns (example hide weight).
I built this code but it doesn't work!!!
could you help me ?
I specify that I used the class table only to present my problem.
my real data contains around fifty columns and several sheet
proc sort data=sashelp.class out=class ;by sex; run;
data report_data;
set class;
by sex;
if sex ='F' then column_display='limited';
if sex='M' then column_display='all';
run;
ods excel file='C:\temp\class.xlsx'
options(
embedded_footnotes='yes' sheet_name = "#byval1" contents="yes");
PROC REPORT data=report_data;
by sex;
column age sex name height weight;
define age/group;
define sex /display;
define name /display;
define height/mean;
define weight/sum;
compute weight;
if column_display='limited' then call define(_col_,'style',"style={visibility=hidden}");
endcomp;
run;
ods excel close;
Thank you
Try this one :
proc sort data=sashelp.class out=class ;by sex; run;
data report_data;
set class;
by sex;
if sex ='F' then do;column_display='limited';weight=.;end; /*<-----*/
if sex='M' then column_display='all';
run;
ods excel file='C:\temp\class.xlsx'
options(
embedded_footnotes='yes' sheet_name = "#byval1" contents="yes");
PROC REPORT data=report_data;
by sex;
column age sex name height weight;
define age/group;
define sex /display;
define name /display;
define height/mean;
define weight/sum nozero ; /*<-----*/
compute weight;
if column_display='limited' then call define(_col_,'style',"style={visibility=hidden}");
endcomp;
run;
ods excel close;
@Ksharp Thank you Ksharp for your reply.
@Cynthia_sas Thank you Cyntia for the clarification.
I forgot to mention that among my data there are also calculated columns.
This solution works with display and analysis columns but I have difficulty making it work on a calculated column.
Is there a trick to make this work?
Hello,
is there anyone who can help me?
I'm really stuck and I haven't been able to find the solution for almost 2 days 😥😥
Thank you
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 25. Read more here about why you should contribute and what is in it for you!
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.