我正在使用 ODS 输出一个 rtf 文件,其中包含每个仓库的图形,使用仓库 ID 作为值。我需要按每生产 100 个被拒绝产品的升序组织图表。我在 Word 中手动重新排序图表,但现在我被要求为前 20 个仓库而不是前 5 个仓库生成此图,并且不希望手动执行此操作。我创建了一个变量(norder)来指示每个仓库的排名,但是如果我按此排序或尝试将其用作按值,它会弄乱图表。我也尝试过 NOTSORTED 选项,但这不起作用。是否有捷径可寻?下面是我的代码:
proc transpose data=WIDE_war
out=Long_war(rename=(Col1=Value))
name=source;
by norder ID name county zipcode date;
var defect1 defect2;
run;
proc sort data=long_war; by ID name zipcode county; run;
OPTIONS orientation=landscape nodate;
ods rtf file="C:\Users\....Top_10_Warehouse.rtf" STYLE=Styles.rtf bodytitle STARTPAGE=NO;;
ods listing close;
ods noproctitle ;
ODS ESCAPECHAR='^';
title; footnote;
title;
ods graphics on / height=7in width=9in;
ods graphics/noborder;
/*Table*/
/*List name, ID, number of products produced, number of defects, the rate of defects per 100 units produced */
/*sort by descending order of the last number */
ods rtf text= "^{style[fontweight=bold just=c fontsize=14pt]Warehouses with the greatest number of defects per 100 units produced}";
proc sort data=req4; by descending rejrat2; run;
proc print data=req4 noobs label;
var ID name ZIPcode County;
var mean_prod newdefects rejrat2 /style(data)={ width=1in};
run;
* time trend plots;
ods rtf startpage=NOW;
ods rtf text= "^{style[fontweight=bold just=c fontsize=14pt] Trend plot of the warehouses listed in the above table since June 01, 2020}";
proc sgplot data=long_war;
by ID name county ;
title1 "ID= #byval(ID) ";
title2 "Name: #byval(name) ";
title3 "County: #byval(county) ";
vbar date/ response=Value group=source groupdisplay=stack grouporder=data NOOUTLINE;
xaxis type=linear thresholdmin=0 label="Date"
values=('01jun20'd to '13dec20'd by 7)
labelattrs=(size=12pt weight=bold)
valueattrs=(size=13pt);
yaxis min=0 label="Count" INTEGER grid
labelattrs=(size=12pt weight=bold)
values=(0 to 35 by 5)
valueattrs=(size=13pt) fitpolicy=thin offsetmin=0 ;
label Source = "Defects by type"
Value = "Count";
options NOBYLINE;
run;
ods rtf close;
ods listing ;