<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic table of contents PDF in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/table-of-contents-PDF/m-p/881523#M348317</link>
    <description>&lt;P&gt;Good afternoon,&lt;BR /&gt;we are coding in SAS to generate a table of contents.&lt;BR /&gt;We are trying it with&lt;/P&gt;&lt;PRE&gt;PDF FILE="/home/test_toc.pdf" CONTENTS=YES ;&lt;/PRE&gt;&lt;P&gt;and adding&lt;/P&gt;&lt;PRE&gt;ODS PROCLABEL="Proc Label 1" ;&lt;/PRE&gt;&lt;P&gt;but somewhere in the code it exits and not everything is executed.&lt;BR /&gt;Do you know any other way to be able to generate a table of contents in PDF?&lt;BR /&gt;Thank you so much!&lt;/P&gt;</description>
    <pubDate>Tue, 20 Jun 2023 11:18:36 GMT</pubDate>
    <dc:creator>Cristina_inet</dc:creator>
    <dc:date>2023-06-20T11:18:36Z</dc:date>
    <item>
      <title>table of contents PDF</title>
      <link>https://communities.sas.com/t5/SAS-Programming/table-of-contents-PDF/m-p/881523#M348317</link>
      <description>&lt;P&gt;Good afternoon,&lt;BR /&gt;we are coding in SAS to generate a table of contents.&lt;BR /&gt;We are trying it with&lt;/P&gt;&lt;PRE&gt;PDF FILE="/home/test_toc.pdf" CONTENTS=YES ;&lt;/PRE&gt;&lt;P&gt;and adding&lt;/P&gt;&lt;PRE&gt;ODS PROCLABEL="Proc Label 1" ;&lt;/PRE&gt;&lt;P&gt;but somewhere in the code it exits and not everything is executed.&lt;BR /&gt;Do you know any other way to be able to generate a table of contents in PDF?&lt;BR /&gt;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2023 11:18:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/table-of-contents-PDF/m-p/881523#M348317</guid>
      <dc:creator>Cristina_inet</dc:creator>
      <dc:date>2023-06-20T11:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: table of contents PDF</title>
      <link>https://communities.sas.com/t5/SAS-Programming/table-of-contents-PDF/m-p/881528#M348320</link>
      <description>&lt;P&gt;The following is the code I wrote before to generate a PDF version of define.xml . Hope could help you a little bit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let path=%sysfunc(prxchange(s/[^\\]+$//,1,%sysget(SAS_EXECFILEPATH))); 
options orientation=landscape validvarname=any varlenchk=nowarn nonumber nodate  ; *nocenter;


/*原始数据库 的路径*/
libname data v9 "&amp;amp;path.SAS" access=readonly;

/*研究标识*/
%let study_id= C20LBE003;

/*第一页的title*/
%let title= 奥美拉唑胶囊-非CDISC标准原始数据库 ;

/*版本*/
%let version= 01.1 / 2020-11-12  ;











/*导入 附加 的数据说明 - 结构 , 来源 , 外部词典*/
proc import datafile="&amp;amp;path.数据说明.xlsx" out=add_table dbms=xlsx replace;
sheet='表单';
run;
proc import datafile="&amp;amp;path.数据说明.xlsx" out=add_var dbms=xlsx replace;
sheet='变量';
run;
proc import datafile="&amp;amp;path.数据说明.xlsx" out=add_dictionary dbms=xlsx replace;
sheet='外部词典';
run;

/*产生字典表*/
proc sql;
create table define_xml_tables as
select a.*,b.基本结构描述 ,1 as _id_ from  /*产生 _id_ 变量,用于去掉 书签'表1'*/
(
select memname,memlabel
 from dictionary.tables
  where libname='DATA' and memname ne 'CODELIST'
) as a left join add_table as b 
   on a.memname=b.数据集名
    order by 1;

create table define_xml_columns as
select a.*,b.来源 label='来源/方法/注释',1 as _id_ from   /*产生 _id_ 变量,用于去掉 书签'表1'*/
(
select memname ,name label='变量',label label='标签/描述',type label='类型',length label='长度或显示格式',varnum label='变量序号'
 from dictionary.columns
  where libname='DATA'
) as a left join add_var as b
   on a.memname=b.数据集名 and a.name=b.变量名
    order by 1,2;
quit;


/*处理 Code List, 一个变量 对应 一行*/
proc sort data=data.codelist out=codelist  ;by DS FIELD;run;
data codelist_1;
do until(last.FIELD);
 set codelist;
 by DS FIELD;
 length dictionary $ 400;
 dictionary=catx(',',dictionary,cats('"',value,'"="',TEXT,'"'));
end;
keep DS FIELD dictionary;
label dictionary='受控术语或ISO格式';
run;
/*将 CodeList 拼进 字典表 define_xml_columns*/
data define_xml_columns_1;
 merge define_xml_columns(in=ina) codelist_1(rename=(ds=memname FIELD=name));
 by memname name;
 if ina ;
run;
proc sort data=define_xml_columns_1 sortseq=linguistic(numeric_collation=on); by memname varnum;run;
proc sort data=codelist sortseq=linguistic(numeric_collation=on); by DS FIELD;run;
/* 取有 值的 CodeList*/
data codelist_2;
 set  define_xml_columns_1 ;
 if not missing(dictionary);
run;


/*添加 '位置' 列*/
data define_xml_tables;
 set define_xml_tables;
length position $ 40 ;
memname=lowcase(memname);
position=cats(memname,'.xpt');
label position='位置';
run;
/*产生 _id_ 变量,用于去掉 书签'表1'*/
data codelist;
 set codelist;
 _id_=1;
run;
/*产生 _id_ 变量,用于去掉 书签'表1'*/
data add_dictionary;
 set add_dictionary;
 _id_=1;
run;



ods _all_ close;
ods pdf  file="&amp;amp;path.define_xml.pdf"  style=sasweb ;

footnote j=l "版本： &amp;amp;version " j=r '(*ESC*){thispage} / (*ESC*){lastpage}';

title j=l "&amp;amp;title" j=r "研究标识: &amp;amp;study_id";
ods proclabel= "&amp;amp;title" ;
/*打印 第一张 表*/
proc report data=define_xml_tables(where=(memname is not missing)) nowd contents='' split='*'  style(report)={outputwidth=100% rules=all};
define memname/display '数据集';
define memlabel/display '描述';
define _id_/order noprint;
compute memlabel;
rtag = "#"||strip(memname);
call define(_col_,'url',rtag);
call define(_col_,'style','style={foreground=blue}');
n+1;
if mod(n,2)=1 then call define(_row_,'style','style={background=verylightgrey}');
endcomp;

compute position;
call define(_col_,'url',".\厦门恩成- 艾司奥美拉唑镁碳酸氢钠胶囊-非CDISC标准原始数据库-20201123\3.原始数据库\XPT\");
call define(_col_,'style','style={foreground=blue}');
endcomp;

break before _id_/page contents='';
run;
/*打印 各表结构*/
data _null_;
 set define_xml_tables(where=(memname is not missing));
 call execute(catt('ods pdf anchor="',strip(memname),'" startpage=now ;
                    ods proclabel="',memlabel,'";
                    title j=l "',memlabel,'" j=r "研究标识: &amp;amp;study_id";',
                  'proc report data=define_xml_columns_1( where=(memname="',upcase(memname),'")) nowd split="*" contents="" 
                     style(report)={outputwidth=100% rules=all}
                     style(header)={font_weight=bold} ;
					 columns memname name label type length dictionary 来源 _id_;
                     define memname/display noprint;
					 define _id_/order noprint;
					 compute dictionary;
                      rtag = "#"||strip(name);
                      call define(_col_,"url",rtag);
                      call define(_col_,"style","style={foreground=blue}");
					  n+1;
                      if mod(n,2)=1 then call define(_row_,"style","style={background=verylightgrey}");
                     endcomp;
					 break before _id_/page contents="";
                   run;title " "; ' ));
run;
/*打印 控制项 Code List*/
data _null_;
 set codelist_2(where=(memname is not missing));
 call execute(catt('ods pdf anchor="',strip(name),'" startpage=now;
                    ods proclabel="',label,'";
                    title j=l "',label,'" j=r "研究标识: &amp;amp;study_id";',
                  'proc report data=codelist( where=(DS="',upcase(memname),'" and FIELD="',upcase(name),'")) nowd split="*" contents="" 
                   style(report)={outputwidth=100% rules=all}
                   style(header)={font_weight=bold} ;
				   define ds/display noprint;
				   define FIELD/display noprint;
				   define value/display "允许值（代码）";
				   define text/display "显示值（解码）";
				   define _id_/order noprint;
				   compute ds;
                     n+1;
                     if mod(n,2)=1 then call define(_row_,"style","style={background=verylightgrey}");
				   endcomp;
				   break before _id_/page contents="";
                   run; title " "; ' ));  /* 或者 title; */
run;
/*打印 外部词典*/
title j=l "外部词典" j=r "研究标识: &amp;amp;study_id";
ods proclabel= "外部词典" ;
proc report data=add_dictionary(where=(参考名称 is not missing)) nowd contents='' split='*'  style(report)={outputwidth=100% rules=all};
define _id_/order noprint;
break before _id_/page contents=''; /*去掉左边标签*/
run;
title ' ';
ods pdf close;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1687262100667.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85170iA6437E15CBA844A3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1687262100667.png" alt="Ksharp_0-1687262100667.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2023 11:54:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/table-of-contents-PDF/m-p/881528#M348320</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-06-20T11:54:59Z</dc:date>
    </item>
  </channel>
</rss>

