想把txt输出改成pdf格式输出,有什么简单方法,求教,感谢!
程序如下:
libname random "E:\random";
%macro random;
%window main
//// @10 "请输入名称" @40 index 20 attr=underline
// @10 "请输入总数" @40 n 4 attr=underline
// @10 "请输入组数" @40 ngrp 4 attr=underline
// @10 "请输入组间比例" @40 ratio 8 attr=underline
@50 "(1:1、2:1:1等形式)"
// @10 "请输入区组长度" @40 rand 4 attr=underline
// @10 "请输入种子数" @40 seed 10 attr=underline
//// @10 "按ENTER键继续" ;
%display main;
data _null_;
file "E:\random\&index.随机结果.txt" ;
put
//// "&index.随机设计参数"
// @1 22*"━"
/ @2 "总样本数" @20 "&n."
/ @2 "组数" @20 "&ngrp."
/ @2 "组间比例" @20 "&ratio."
/ @2 "区组长度" @20 "&rand."
/ @2 "随机数种子" @20 "&seed."
/ @1 22*"━"
;
run;
%let s=0;
%do i=1 %to &ngrp;
%let ratio&i=%scan(&ratio,&i,:);
%let s=%eval(&s+&&ratio&i);
%end;
ods listing close;
ods output plan=plan;
proc plan seed=&seed.;
factors block=%eval( &n./ &rand.)
rand=&rand.;
output out=temp1
rand cvals=( %do i=1 %to %eval(&rand/&s);
%do j=1 %to &ngrp;
%do k=1 %to &&ratio&j;
"%sysfunc(byte(&j+64))"
%end ;%end;%end;);
quit;
ods listing;
data temp1(drop=rand);
set temp1;
D=_n_;
group=rand || "组";
run;
data _null_;
set temp1 end=final;
ID=put(D, z3.);
file "E:\random\&index.随机结果.txt" mod;
if _n_=1 then put // @1 "&index.随机数字表"
// @2 "编号" @12 "分组"
/ @1 8*"━";
put @2 id @12 group ;
if final then put @1 8*"━";
run;
data _null_;
file "E:\random\&index.包装表.txt" ;
put
//// "&index.随机设计参数"
// @1 22*"━"
/ @2 "总样本数" @20 "&n."
/ @2 "组数" @20 "&ngrp."
/ @2 "组间比例" @20 "&ratio."
/ @2 "区组长度" @20 "&rand."
/ @2 "随机数种子" @20 "&seed."
/ @1 22*"━"
;
run;
proc sort data=temp1 out=temp2;
by group;
run;
data _null_;
set temp2 end=final;
ID=put(D, z3.);
file "E:\random\&index.包装表.txt" mod;
if _n_=1 then put // @1 "&index.包装表"
// @2 "编号" @12 "分组"
/ @1 8*"━";
put @2 id @12 group ;
if final then put @1 8*"━";
run;
proc delete data=temp1 temp2 plan;
quit;
%mend random;
%random;