Help using Base SAS procedures

proc document questions - TOC, proc report

Reply
Occasional Contributor
Posts: 6

proc document questions - TOC, proc report

Hi all,

After searching for a while to manipulate the TOC with output to PDF from proc report, I managed to create the TOC that I desired.

However, I found that the style attributes for the titles in my proc report are gone as a result.  Anyone knows the reason?

I also found that with my codes below, I get the same reports printed twice:  one set would have no desired TOC, and the later sets would.

If someone can spot any wrong codings, please let me know.  Thanks!

title;

footnote;

ods listing close;

ods pdf file=&out3;

%title;

%macro report;

title;

ods document name=report (write);

%do i=1 %to 89;

options nodate nonumber orientation=landscape;

proc report data=final_fac7 nowd contents="&&fac&i";

title1 j=c c=brown " xxxxx ";

title2 j=c c=purple h=2 "Reporting Period: xxxx";

column and define statements......

where statement;

%end;

ods document close;

%macro bookmark1;

proc document name=report_fac(update);

%do i=2 %to 5;

move report#&i\report#1 to report#1;

setlabel report#1 "&lname1";

delete report#&i;

run;

%end;

%mend bookmark1;

%bookmark1;

ods pdf file=&out3;

replay;

run;

ods pdf close;

%mend;

ods listing;

%report;

title;

%appendixA;

%appendixB;

ods pdf close;

ods listing;

SAS Super FREQ
Posts: 8,745

Re: proc document questions - TOC, proc report

Hi:

  Hmmmm, when I run the simplified code below, I DO see the colors used in the titles in the new output files on REPLAY with ODS DOCUMENT. So I think this is a question for Tech Support. Even with macro involved, I would expect the behavior to be the same. (I ran my example using SAS 9.3 on Windows 7)

cynthia

ods listing close;

** 1) Make an ODS Document from PROC REPORT and;

**    and use style changes for the title;

ods html file='c:\temp\test_title.html' style=htmlblue;

ods pdf file='c:\temp\test_title.pdf';

ods document name=work.test_title(write);

  

proc report data=sashelp.class (obs=3) nowd;

  title1 j=c c=brown " xxxxx ";

  title2 j=c c=purple h=2 "Reporting Period: yyyy";

run;

ods document close;

ods _all_ close;

       

title;

        

**2) Replay the new document store to HTML and PDF and see if the title colors are used.;

** change the colors for HTML to see that new style is applied, but original title changes persist;

ods html file='c:\temp\replay_title.html' style=sasweb;

ods pdf file='c:\temp\replay_title.pdf';

proc document name=work.test_title;

  replay;

run;

quit;

   

ods html close;

ods pdf close;

Occasional Contributor
Posts: 6

Re: proc document questions - TOC, proc report

Hi Cynthia,

Thank you for your reply.  Everything behaved the way they should be when I run the simplied codes like the one you listed above.  However, when I used this procedure in a more complex manner with macro and with the moving of the reports to make desired TOC, then the style attributes stopped working and printing to PDF was not right either.

I have contacted Tech Support.

Thanks,

Super User
Posts: 10,550

Re: proc document questions - TOC, proc report

Your example code may be scrambled. It appears to use the macro BOOKMARK1 before it is defined.

I would recommend moving the macro definitions outside of the ODS PDF open/close "sandwich" to make sure the code you intend is being sent to the ODS desinations you want. Along with that, I would look closely at your ODS PDF CLOSE statements. It appears that you have two closes for ODS PDF which may be part of the issue about two sets of reports.

Occasional Contributor
Posts: 6

Re: proc document questions - TOC, proc report

Hi ballardw,

Thank you for your comment.  I removed the second ods pdf close statement, and also tried moving the macro definite outside of the ods pdf open/close sandwich.  Unfortunately the result is still the same as before Smiley Sad.

Zoe

SAS Super FREQ
Posts: 8,745

Re: proc document questions - TOC, proc report

Hi:

  There are a lot of other little things that I'm not sure about -- which is why I recommended that you open a track with Tech Support. Besides the other issues (using the macro before you define it and having mismatched close statements, etc) some other comments:

1) usually, file= is a quoted string and your &OUT3 is not shown inside quotes

2) I would only MAKE the document store inside the ODS PDF "sandwich" -- if I wanted to get a "before" picture of what the original bookmark structure or document structure looked like. Also, I don't usually recommend that you manipulate the document store with ODS DOCUMENT or PROC DOCUMENT inside an ODS "sandwich". Generally, I manipulate the document store outside the ODS sandwich and keep my REPLAY very very simple. -- so that the REPLAY is the ONLY thing inside the ODS sandwich. If you need to "macro-ize" the rearranging of the report objects, I would do that outside of the ODS sandwich -- get your whole document rearranged -- and then do a REPLAY.

3) I am not convinced that your syntax inside the PROC DOCUMENT step is entirely correct. If looks like you are ALWAYS issuing a SETLABEL to be the same thing, no matter how many times you iterate through the loop. SETLABEL is always &LNAME1 -- so that is something else I don't understand. I would almost have expected to see something like &&LNAME&I as the value here.

4) In general, I find your flow confusing. I recommend in general that you create your document store in total. Then you make a new document store and start copying items into the new document store (instead of moving things in the original document store). I do this for several reasons: it is easier to "debug" -- I don't accidentally trash the document store with a miscoded MOVE; I always have the original to fall back to and look at; it helps me to see the whole original document store and the bookmarks generated for the that original document, in total BEFORE I even write my first PROC DOCUMENT manipulation -- so that I can see exactly which objects I want to copy into which structure in the new document.

So my suggestion is still that you work with Tech Support on this.

cynthia

Occasional Contributor
Posts: 6

Re: proc document questions - TOC, proc report

Hi Cynthia,

Thank you for your comments.  I am relatively new to SAS so anything helps.   I am working with Tech Support on this.

1.  I found that if I put &OUT3 in quoted string - I get screwed up table. I am using SAS9.2.

2. I will try what you suggsted.

3. I actually want to move several reports to the 1st level node. So SETLABEL is always &LNAME1 (the name for my first level-node).  Or is there another way to do this?

4. Can you tell me where I can find resources about copying items?

Thanks,

Zoe

SAS Super FREQ
Posts: 8,745

Re: proc document questions - TOC, proc report

Hi:

  The ODS DOCUMENT/PROC DOCUMENT information in the documentation is very good. I did write a paper about ODS DOCUMENT with an example of the method that I mentioned (making the "original" document store, then making a new document store and then copying into the new structure). That URL is here: http://support.sas.com/resources/papers/sgf09/318-2009.pdf

  You will want to look at the documentation for the 9.2 version of ODS DOCUMENT. You can search for specific levels of the doc in the on-line search.

  If you only have 1 node, it doesn't make sense to keep assigning SETLABEL over and over again. I'd probably build the new structure and then do the SETLABEL as a final step (and possibly separate PROC DOCUMENT step) before the REPLAY.

  I also recommend that you have at least 1 version of your program that works without using any macro processing before you introduce macro into the mix. Did you start with a working SAS program? Even if you have to hardcode the creation of 3 PROC REPORT steps (instead of 89), having working, non-macro code for creating your ODS DOCUMENT with 3 PROC REPORTS and then doing the manipulation would be an instructive exercise and would give you a better idea of how and where and what you need to macroize.

cynthia

Ask a Question
Discussion stats
  • 7 replies
  • 295 views
  • 0 likes
  • 3 in conversation