PROC REPORT :是否可以不打印特定行?
PROC REPORT : Is it possible to don't print a specific row?
我正在使用 PROC REPORT 向 Excel 撰写报告。第一列被分组,我在它的一些值之前添加了一个断线。如果符合某些条件,则此分隔线包含列的值。
例如
我的 table 包含以下行:
nom_var | val1 | val2 | val3 |
_____________________________________________________
Identification | . | . | . |
Name | Ou. Dj. | . | . |
date B. | 00/01/31 | . | . |
NAS | 1122334 | . | . |
Revenues | . | . | . |
| R1 1250 $ | R2 1000 $ | . |
_____________________________________________________
在我的报告中:
_____________________________________________________
Identification
_____________________________________________________
Identification | . | . | . |
Name | Ou. Dj. | . | . |
date B. | 00/01/31 | . | . |
NAS | 1122334 | . | . |
____________________________________________________
Revenues
_____________________________________________________
Revenues | . | . | . |
| R1 1250 $ | R2 1000 $ | . |
_____________________________________________________
请问,如何删除第一列 "nom_var" 中包含 "Identification" 和 "Revenues" 的行?
我的意思是:
Identification | . | . | . |
和
Revenues | . | . | . |
这是我的代码:
ods listing close;
*options générales;
options topmargin=1in bottommargin=1in
leftmargin=0.25in rightmargin=0.25in
;
%let fi=%sysfunc(cat(%sysfunc(compress(&nom)),_portrait_new.xls));
ods tagsets.ExcelXP path="&cheminEx." file="&fi" style=seaside
options(autofit_height="yes"
pagebreaks="yes"
orientation="portrait"
papersize="letter"
sheet_interval="none"
sheet_name="Infos Contribuable"
WIDTH_POINTS = "12" WIDTH_FUDGE = ".0625" /* absolute_column_width est en pixels*/
absolute_column_width="120,180,160,150"
);
ods escapechar="^";
*rapport1;
/*contribuable*/
proc report data=&lib..portrait nowindows missing spanrows noheader
style(report)=[frame=box rules=all
foreground=black Font_face='Times New Roman' font_size=10pt
background=none]
style(column)=[Font_face='Times New Roman' font_size=10pt just=left]
;
/*entête du tableau est la première variable de la table ==> à gauche du rapport */
define nom_var / group order=data style(column)=[verticalalign=middle
background=#e0e0e0 /* gris */
foreground=blue
fontweight=bold
];
/* Contenu */
define valeur_var1 / style(column)=[verticalalign=top];
define valeur_var2 / style(column)=[verticalalign=top];
define valeur_var3 / style(column)=[verticalalign=top];
compute before nom_var / style=[verticalalign=middle background=#e0e0e0
foreground=blue fontweight=bold font_size=12pt];
length rg $ 50;
if nom_var in ("Identification","Actifs", "Revenus") then do;
rg= nom_var;
len=50;
end;
else do;
rg="";
len=0;
end;
line rg $varying50. len;
endcomp ;
title j=center height=12pt 'Portrait du contribuable';
run;
ods tagsets.ExcelXP close;
ods listing;
您有一个人工数据构造,其分类形式不适合输出信息行的任务。
此示例展示了数据步骤如何调整数据,因此您有一个 mySection
变量来组织由感兴趣的 nom_var 行引入的行(Identification
和 Revenues
)
新的数据排列更适合您正在执行的任务。
data have;
length nom_var val1 val2 val3 ;
infile cards dlm='|';
input
nom_var val1 val2 val3 ;
datalines;
Identification | . | . | . |
Name | Ou. Dj. | . | . |
date B. | 00/01/31 | . | . |
NAS | 1122334 | . | . |
Revenues | . | . | . |
| R1 1250 $ | R2 1000 $ | . |
run;
调整原始数据,使分类 mySection
data need;
set have;
retain mySection;
select (nom_var);
when ('Identification') mySection = nom_var;
when ('Revenues') mySection = nom_var;
otherwise OUTPUT; * NOTE: Explicit OUTPUT means there is no implicit OUTPUT, which means the rows that do mySection= are not output;
end;
run;
使用新变量 (mySection
) 进行分组 (compute before
),但保持其列隐藏 (noprint
)
proc report data=need;
column mySection nom_var val1 val2 val3;
define mySection / group noprint;
compute before mySection;
line mySection .;
endcomp;
run;
我正在使用 PROC REPORT 向 Excel 撰写报告。第一列被分组,我在它的一些值之前添加了一个断线。如果符合某些条件,则此分隔线包含列的值。
例如
我的 table 包含以下行:
nom_var | val1 | val2 | val3 |
_____________________________________________________
Identification | . | . | . |
Name | Ou. Dj. | . | . |
date B. | 00/01/31 | . | . |
NAS | 1122334 | . | . |
Revenues | . | . | . |
| R1 1250 $ | R2 1000 $ | . |
_____________________________________________________
在我的报告中:
_____________________________________________________
Identification
_____________________________________________________
Identification | . | . | . |
Name | Ou. Dj. | . | . |
date B. | 00/01/31 | . | . |
NAS | 1122334 | . | . |
____________________________________________________
Revenues
_____________________________________________________
Revenues | . | . | . |
| R1 1250 $ | R2 1000 $ | . |
_____________________________________________________
请问,如何删除第一列 "nom_var" 中包含 "Identification" 和 "Revenues" 的行?
我的意思是:
Identification | . | . | . |
和
Revenues | . | . | . |
这是我的代码:
ods listing close;
*options générales;
options topmargin=1in bottommargin=1in
leftmargin=0.25in rightmargin=0.25in
;
%let fi=%sysfunc(cat(%sysfunc(compress(&nom)),_portrait_new.xls));
ods tagsets.ExcelXP path="&cheminEx." file="&fi" style=seaside
options(autofit_height="yes"
pagebreaks="yes"
orientation="portrait"
papersize="letter"
sheet_interval="none"
sheet_name="Infos Contribuable"
WIDTH_POINTS = "12" WIDTH_FUDGE = ".0625" /* absolute_column_width est en pixels*/
absolute_column_width="120,180,160,150"
);
ods escapechar="^";
*rapport1;
/*contribuable*/
proc report data=&lib..portrait nowindows missing spanrows noheader
style(report)=[frame=box rules=all
foreground=black Font_face='Times New Roman' font_size=10pt
background=none]
style(column)=[Font_face='Times New Roman' font_size=10pt just=left]
;
/*entête du tableau est la première variable de la table ==> à gauche du rapport */
define nom_var / group order=data style(column)=[verticalalign=middle
background=#e0e0e0 /* gris */
foreground=blue
fontweight=bold
];
/* Contenu */
define valeur_var1 / style(column)=[verticalalign=top];
define valeur_var2 / style(column)=[verticalalign=top];
define valeur_var3 / style(column)=[verticalalign=top];
compute before nom_var / style=[verticalalign=middle background=#e0e0e0
foreground=blue fontweight=bold font_size=12pt];
length rg $ 50;
if nom_var in ("Identification","Actifs", "Revenus") then do;
rg= nom_var;
len=50;
end;
else do;
rg="";
len=0;
end;
line rg $varying50. len;
endcomp ;
title j=center height=12pt 'Portrait du contribuable';
run;
ods tagsets.ExcelXP close;
ods listing;
您有一个人工数据构造,其分类形式不适合输出信息行的任务。
此示例展示了数据步骤如何调整数据,因此您有一个 mySection
变量来组织由感兴趣的 nom_var 行引入的行(Identification
和 Revenues
)
新的数据排列更适合您正在执行的任务。
data have;
length nom_var val1 val2 val3 ;
infile cards dlm='|';
input
nom_var val1 val2 val3 ;
datalines;
Identification | . | . | . |
Name | Ou. Dj. | . | . |
date B. | 00/01/31 | . | . |
NAS | 1122334 | . | . |
Revenues | . | . | . |
| R1 1250 $ | R2 1000 $ | . |
run;
调整原始数据,使分类 mySection
data need;
set have;
retain mySection;
select (nom_var);
when ('Identification') mySection = nom_var;
when ('Revenues') mySection = nom_var;
otherwise OUTPUT; * NOTE: Explicit OUTPUT means there is no implicit OUTPUT, which means the rows that do mySection= are not output;
end;
run;
使用新变量 (mySection
) 进行分组 (compute before
),但保持其列隐藏 (noprint
)
proc report data=need;
column mySection nom_var val1 val2 val3;
define mySection / group noprint;
compute before mySection;
line mySection .;
endcomp;
run;