PROC REPORT DATA=sashelp.CLASS NOWD
STYLE(header)=[background=CX9BC2E6 foreground=white just=center]
STYLE(column)=[cellwidth=3cm] ;
COLUMN NAME SEX AGE HEIGHT WEIGHT ;
DEFINE NAME / DISPLAY "Nom" ;
DEFINE HEIGHT / DISPLAY "Taille" ;
DEFINE WEIGHT / DISPLAY "Poids" ;
RUN;
ODS Excel CLOSE;
ODS LISTING;
Hello,
I have to create many proc report (many tables). so if I plan to duplicate this proc report code (copy/paste ) .
My problem is : whenever I would like to change the label "Nom" by "Le nom" I should change all proc report.
How could I specify the label at only one place and specify all proc report to get the label corresponding of a column ? and all "proc report" should automatically change whenever the label is changed.
Many thanks in advance
Regards
Nasser
A macro variable would work
%let nom = Nom;
PROC REPORT DATA=sashelp.CLASS NOWD
STYLE(header)=[background=CX9BC2E6 foreground=white just=center]
STYLE(column)=[cellwidth=3cm] ;
COLUMN NAME SEX AGE HEIGHT WEIGHT ;
DEFINE NAME / DISPLAY "&nom" ;
DEFINE HEIGHT / DISPLAY "Taille" ;
DEFINE WEIGHT / DISPLAY "Poids" ;
RUN;
At a later point in time, if you change the value of the macro variable and re-run your PROC REPORTs, the new value will appear in the PROC REPORT output. Example:
%let nom=NAME;
PROC REPORT DATA=sashelp.CLASS NOWD
STYLE(header)=[background=CX9BC2E6 foreground=white just=center]
STYLE(column)=[cellwidth=3cm] ;
COLUMN NAME SEX AGE HEIGHT WEIGHT ;
DEFINE NAME / DISPLAY "&nom" ;
DEFINE HEIGHT / DISPLAY "Taille" ;
DEFINE WEIGHT / DISPLAY "Poids" ;
RUN;
A macro variable would work
%let nom = Nom;
PROC REPORT DATA=sashelp.CLASS NOWD
STYLE(header)=[background=CX9BC2E6 foreground=white just=center]
STYLE(column)=[cellwidth=3cm] ;
COLUMN NAME SEX AGE HEIGHT WEIGHT ;
DEFINE NAME / DISPLAY "&nom" ;
DEFINE HEIGHT / DISPLAY "Taille" ;
DEFINE WEIGHT / DISPLAY "Poids" ;
RUN;
At a later point in time, if you change the value of the macro variable and re-run your PROC REPORTs, the new value will appear in the PROC REPORT output. Example:
%let nom=NAME;
PROC REPORT DATA=sashelp.CLASS NOWD
STYLE(header)=[background=CX9BC2E6 foreground=white just=center]
STYLE(column)=[cellwidth=3cm] ;
COLUMN NAME SEX AGE HEIGHT WEIGHT ;
DEFINE NAME / DISPLAY "&nom" ;
DEFINE HEIGHT / DISPLAY "Taille" ;
DEFINE WEIGHT / DISPLAY "Poids" ;
RUN;
Thanks Paige Mille for your quick response.
sorry, I have an additional question. when the dataset is empty I can not open the external excel file produced. An error message "this file is corrupted".
would it exist a solution to avoid this ?
thanks
Nasser
@Nasser_DRMCP wrote:
Thanks Paige Mille for your quick response.
sorry, I have an additional question. when the dataset is empty I can not open the external excel file produced. An error message "this file is corrupted".
would it exist a solution to avoid this ?
thanks
Nasser
Honestly, I don't see how this relates to the problem you presented, and a lot more detail and explanation is needed here. If there are errors in the log, show us the log.
sorry, below the log .
1 The SAS System Friday, August 12, 2022 01:52:00 PM
1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='nm_technique.sas';
4 %LET _CLIENTPROCESSFLOWNAME='Standalone Not In Project';
5 %LET _CLIENTPROJECTPATH='';
6 %LET _CLIENTPROJECTPATHHOST='';
7 %LET _CLIENTPROJECTNAME='';
8 %LET _SASPROGRAMFILE='/home/ldap/mellouna/sasuser/nm_technique.sas';
9 %LET _SASPROGRAMFILEHOST='**********';
10
11 ODS _ALL_ CLOSE;
12 OPTIONS DEV=PNG;
13 GOPTIONS XPIXELS=0 YPIXELS=0;
14 %macro HTML5AccessibleGraphSupported;
15 %if %_SAS_VERCOMP_FV(9,4,4, 0,0,0) >= 0 %then ACCESSIBLE_GRAPH;
16 %mend;
17
18
19 ODS LISTING CLOSE;
20 ODS EXCEL FILE="$GRPFPU/REQUETES_PROD/MELLOUNA_PROC_REPORT.xlsx" STYLE=HTMLBlue;
21 ODS Excel options ( SHEET_NAME = "Base" );
22
23 PROC REPORT DATA=CLASS_EMPTY NOWD
24 STYLE(header)=[background=CX9BC2E6 foreground=white just=center]
25 STYLE(column)=[cellwidth=3cm] ;
26 COLUMN NAME SEX AGE HEIGHT WEIGHT ;
27 DEFINE NAME / DISPLAY "Le nom" ;
28 DEFINE HEIGHT / DISPLAY "La Taille" ;
29 DEFINE WEIGHT / DISPLAY "Le poids" ;
30 RUN;
NOTE: No observations in data set WORK.CLASS_EMPTY.
NOTE: No observations in input data set.
NOTE: PROCEDURE REPORT used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 460.71k
OS Memory 26316.00k
Timestamp 08/12/2022 03:49:13 PM
Step Count 22 Switch Count 0
Page Faults 0
Page Reclaims 198
Page Swaps 0
Voluntary Context Switches 0
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0
31 ODS Excel CLOSE;
NOTE: Writing EXCEL file: $GRPFPU/REQUETES_PROD/MELLOUNA_PROC_REPORT.xlsx
32 ODS LISTING;
33
34 %LET _CLIENTTASKLABEL=;
35 %LET _CLIENTPROCESSFLOWNAME=;
36 %LET _CLIENTPROJECTPATH=;
37 %LET _CLIENTPROJECTPATHHOST=;
2 The SAS System Friday, August 12, 2022 01:52:00 PM
38 %LET _CLIENTPROJECTNAME=;
39 %LET _SASPROGRAMFILE=;
40 %LET _SASPROGRAMFILEHOST=;
41
42 ;*';*";*/;quit;run;
43 ODS _ALL_ CLOSE;
44
45
46 QUIT; RUN;
You need to fix this part
23 PROC REPORT DATA=CLASS_EMPTY NOWD 24 STYLE(header)=[background=CX9BC2E6 foreground=white just=center] 25 STYLE(column)=[cellwidth=3cm] ; 26 COLUMN NAME SEX AGE HEIGHT WEIGHT ; 27 DEFINE NAME / DISPLAY "Le nom" ; 28 DEFINE HEIGHT / DISPLAY "La Taille" ; 29 DEFINE WEIGHT / DISPLAY "Le poids" ; 30 RUN; NOTE: No observations in data set WORK.CLASS_EMPTY.
ok sorry, my explanations was not clear at all.
sometimes the table is not empty, sometimes it is empty and it is "normal"
in case it is empty, I would like to generate a file only with headers column (and correct label)
I don't know if it is possible
thanks
I have never created a report that has headers only and no data.
I suppose you could create a fake data set with one row of missing data for every variable, and the run PROC REPORT on that fake data set.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.