全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
2714 5
2013-12-06
想把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;


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2013-12-6 18:10:15
好复杂
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-12-6 20:40:54
想输出为pdf格式,求指导!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-12-7 15:16:05
急急急!求指导!!!谢谢先!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-12-27 00:38:59
常用做法是ODS PDF,但要改写程序。
不常用做法是自定义PDF打印机,将TXT转成PDF,但是PDF打印机的字号和边界要根据TXT的LINESIZE和PAGESIZE调整。
下面的例子是将132x79的LISTING OUTPUT转PDF,在UNIX下完成,WINDOWS环境下的OPTIONS可能略有不同。
复制代码
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-12-27 17:45:14
保存一下!
复制代码
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群