楼主: ccgcs
2788 5

想把txt输出改成pdf格式输出 [推广有奖]

  • 0关注
  • 3粉丝

本科生

92%

还不是VIP/贵宾

-

威望
0
论坛币
205 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
2015 点
帖子
114
精华
0
在线时间
101 小时
注册时间
2010-10-18
最后登录
2016-6-6

楼主
ccgcs 发表于 2013-12-6 11:46:54 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
想把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;


二维码

扫码加我 拉你入群

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

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

关键词:pdf格式 PDF txt listing libname display 简单方法 window null file

本帖被以下文库推荐

沙发
夏夜炊烟 发表于 2013-12-6 18:10:15
好复杂

藤椅
ccgcs 发表于 2013-12-6 20:40:54
想输出为pdf格式,求指导!

板凳
ccgcs 发表于 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可能略有不同。
  1. data pdf7p;
  2.         dest        = 'sasprt.pdf';
  3.         hostopt        = ' ';
  4.         desc        = 'PDF (132x79)';
  5.         viewer        = ' ';
  6.         name        = 'PDF7P';
  7.         model        = 'PDF Version 1.4';
  8.         preview        = ' ';
  9.         typeface        = 'Courier';
  10.         papersiz        = 'Letter';
  11.         *papertyp        = '<Default>';
  12.         *paperin                = '<Default>';
  13.         *paperout        = '<Default>';
  14.         res        = '300 DPI';
  15.         weight        = 'Normal';
  16.         style        = 'Regular';
  17.         charset        = 'Western';
  18.         protocol        = ' ';
  19.         device        = 'DISK';
  20.         trantab        = ' ';
  21.         units        = 'IN';
  22.         lrecl        = 255;
  23.         top        = 1.5;
  24.         left        = .5;
  25.         right        = .5;
  26.         bottom        = 1.5;
  27.         fontsize        = 7;
  28. proc prtdef data=pdf7p replace;
  29. run;
  30. options printerpath=(pdf7p myprint)
  31.                 ls=132 ps=79
  32.                 orientation=portrait
  33.         nodate
  34. ;
  35. filename myprint "example.pdf";
  36. filename myuprt uprinter;

  37. proc printto print=myuprt;
  38. data _null_;
  39.         file print notitles;
  40.         infile "example.txt";
  41.         input;
  42.         put _infile_;
  43. run;
  44. proc printto;
  45. run;
复制代码
Be still, my soul: the hour is hastening on
When we shall be forever with the Lord.
When disappointment, grief and fear are gone,
Sorrow forgot, love's purest joys restored.

地板
dxystata 发表于 2013-12-27 17:45:14
保存一下!
  1. libname random "E:\random";

  2. %macro random;
  3. %window main

  4. ////  @10 "请输入名称" @40 index 20 attr=underline

  5. // @10 "请输入总数" @40 n 4 attr=underline

  6. // @10 "请输入组数" @40 ngrp 4 attr=underline

  7. // @10 "请输入组间比例" @40 ratio 8 attr=underline
  8.    @50 "(1:1、2:1:1等形式)"

  9. // @10 "请输入区组长度" @40 rand 4 attr=underline

  10. // @10 "请输入种子数" @40 seed 10 attr=underline

  11. //// @10 "按ENTER键继续"  ;

  12. %display main;


  13. data _null_;
  14. file "E:\random\&index.随机结果.txt" ;
  15. put
  16. ////  "&index.随机设计参数"
  17. //   @1 22*"━"
  18. /    @2 "总样本数"    @20 "&n."
  19. /    @2 "组数"        @20 "&ngrp."
  20. /    @2 "组间比例"    @20 "&ratio."
  21. /    @2 "区组长度"    @20 "&rand."
  22. /    @2 "随机数种子"  @20 "&seed."
  23. /    @1 22*"━"
  24. ;
  25. run;

  26. %let s=0;
  27. %do i=1 %to &ngrp;
  28.         %let ratio&i=%scan(&ratio,&i,:);
  29.         %let s=%eval(&s+&&ratio&i);
  30. %end;

  31. ods listing close;
  32. ods output plan=plan;
  33. proc plan seed=&seed.;
  34.    factors block=%eval( &n./ &rand.)
  35.            rand=&rand.;
  36. output out=temp1
  37.        rand cvals=(        %do i=1 %to %eval(&rand/&s);
  38.                                           %do j=1 %to &ngrp;
  39.                                                 %do k=1 %to &&ratio&j;
  40.                             "%sysfunc(byte(&j+64))"
  41.                     %end ;%end;%end;);
  42. quit;
  43. ods listing;

  44. data temp1(drop=rand);
  45. set temp1;
  46. D=_n_;
  47. group=rand || "组";
  48. run;

  49. data _null_;
  50. set temp1 end=final;
  51. ID=put(D, z3.);
  52. file "E:\random\&index.随机结果.txt" mod;
  53. if _n_=1 then put // @1 "&index.随机数字表"
  54.                   // @2 "编号" @12 "分组"
  55.                   / @1 8*"━";
  56. put  @2 id  @12 group ;
  57. if final then  put @1 8*"━";
  58. run;

  59. data _null_;
  60. file "E:\random\&index.包装表.txt" ;
  61. put
  62. ////  "&index.随机设计参数"
  63. //   @1 22*"━"
  64. /    @2 "总样本数"    @20 "&n."
  65. /    @2 "组数"        @20 "&ngrp."
  66. /    @2 "组间比例"    @20 "&ratio."
  67. /    @2 "区组长度"    @20 "&rand."
  68. /    @2 "随机数种子"  @20 "&seed."
  69. /    @1 22*"━"
  70. ;
  71. run;

  72. proc sort data=temp1 out=temp2;
  73. by group;
  74. run;

  75. data _null_;
  76. set temp2 end=final;
  77. ID=put(D, z3.);
  78. file "E:\random\&index.包装表.txt" mod;
  79. if _n_=1 then put // @1 "&index.包装表"
  80.                   // @2 "编号" @12 "分组"
  81.                  / @1 8*"━";
  82. put  @2 id  @12 group ;
  83. if final then put @1 8*"━";
  84. run;

  85. proc delete data=temp1 temp2 plan;
  86. quit;
  87. %mend random;

  88. %random;
复制代码

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-25 19:13