BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ScottBass
Rhodochrosite | Level 12

Hi,

SAS 9.2 on Windows

Submit this code:

filename temp temp;

options orientation=portrait nodate nonumber spool;

ods _all_ close;

ods escapechar = '^';

ods pdf file=temp notoc startpage=no style=SeasidePrinter;

title;

footnote;

proc report data=sashelp.class nowd;

  where name =: "A";

  columns sex age name height weight;

  define sex    / order;

  define age    / order;

  define name   / display;

  define height / analysis;

  define weight / analysis;

quit;

proc report data=sashelp.shoes nowd;

quit;

ods pdf close;

ods listing;

Is there a way I can prevent sashelp.shoes from starting on a new page?

In my "real report", the proc report sashelp.class code is a page header, displaying the parameters for the report.  It looks a bit weird to see the report header page, a blank data portion, then the data portion begins on a second page (without a header).

What would be really cool is for the page header to print on each page of a multi page output.  IOW, sashelp.class would print at the top of each page of the sashelp.shoes output.  AFAIK, I could probably get this to work using the ODS Data Step Interface, but at this point in my project that would involve too much of a re-write.

Thanks,

Scott


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

If you do your own summary I believe you can get pretty much everything you want.  Including no TOTAL row when N=1.

filename temp temp;

options orientation=portrait nodate nonumber spool;

ods _all_ close;

ods escapechar = '^';

ods pdf file=temp notoc startpage=no style=SeasidePrinter;

title;

footnote;

proc report data=sashelp.class nowd;

  where name =: "A";

  columns sex age name height weight;

  define sex    / order;

  define age    / order;

  define name   / display;

  define height / analysis;

  define weight / analysis;

quit;

proc summary data=sashelp.shoes missing chartype;

   class region subsidiary product;

   types region region*subsidiary region*subsidiary*product;

   var sales;

   output out=sum sum=;

   run;

data sum;

   set sum;

   if _type_ eq '110' and _freq_ eq 1 then delete;

   subsidiary = coalesceC(subsidiary,'ff'x);

   product    = coalesceC(product,'ff'x);

   run;

proc format;

   value $fftot(default=64) 'ff'x='Total';

   run;

proc sort data=sum;

   by region subsidiary product;

   run;

proc report data=sum(obs=49) nowd spanrows missing;

   columns region subsidiary product sales;

   define region           / order order=interna;

   define subsidiary       / order order=internal format=$fftot.;

   define product          / order order=internal format=$fftot.;

   define sales            / analysis;

   run;  

proc report data=sum(firstobs=50) nowd spanrows missing;

   columns region subsidiary product sales;

   define region           / order ;

   define subsidiary       / order order=internal format=$fftot.;

   define product          / order order=internal format=$fftot.;

   define sales            / analysis;

   run;  

ods pdf close;

ods listing;

View solution in original post

4 REPLIES 4
data_null__
Jade | Level 19

Not an answer but if you print a subset of obs from SHOES to fit on the page it will be on the same page as CLASS.

Something like this might work for you.

proc report data=sashelp.shoes(obs=20) nowd;

   run;

proc report data=sashelp.shoes(firstobs=21) nowd;

   run;

ScottBass
Rhodochrosite | Level 12

Hi Data,

Sorry, I oversimplified my example.  My "real" report looks more like:

proc report data=sashelp.class nowd;

  where name =: "A";

  columns sex age name height weight;

  define sex    / order;

  define age    / order;

  define name   / display;

  define height / analysis;

  define weight / analysis;

quit;

proc report data=sashelp.shoes nowd spanrows;

  columns region subsidiary product sales;

  define region           / order;

  define subsidiary       / order;

  define product          / display;

  define sales            / analysis;

  break after region / summarize;

  break after subsidiary / summarize;

  compute after region;

    call missing(subsidiary,product);

  region="Total";

  endcomp;

  compute after subsidiary;

    call missing(region,subsidiary);

  product="Total";

  endcomp;

quit;

The obs/firstobs approach causes a partial subtotal to appear on the first page, then a partial subtotal on the final page, which the end user will find confusing.

Great idea - apologies my example code was oversimplified.

Regards,

Scott

P.S.: Thanks for the tip for SPANROWS in the other thread.  The break after and compute after code messes that up slightly, but it's still closer to what the end user wants.


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
data_null__
Jade | Level 19

If you do your own summary I believe you can get pretty much everything you want.  Including no TOTAL row when N=1.

filename temp temp;

options orientation=portrait nodate nonumber spool;

ods _all_ close;

ods escapechar = '^';

ods pdf file=temp notoc startpage=no style=SeasidePrinter;

title;

footnote;

proc report data=sashelp.class nowd;

  where name =: "A";

  columns sex age name height weight;

  define sex    / order;

  define age    / order;

  define name   / display;

  define height / analysis;

  define weight / analysis;

quit;

proc summary data=sashelp.shoes missing chartype;

   class region subsidiary product;

   types region region*subsidiary region*subsidiary*product;

   var sales;

   output out=sum sum=;

   run;

data sum;

   set sum;

   if _type_ eq '110' and _freq_ eq 1 then delete;

   subsidiary = coalesceC(subsidiary,'ff'x);

   product    = coalesceC(product,'ff'x);

   run;

proc format;

   value $fftot(default=64) 'ff'x='Total';

   run;

proc sort data=sum;

   by region subsidiary product;

   run;

proc report data=sum(obs=49) nowd spanrows missing;

   columns region subsidiary product sales;

   define region           / order order=interna;

   define subsidiary       / order order=internal format=$fftot.;

   define product          / order order=internal format=$fftot.;

   define sales            / analysis;

   run;  

proc report data=sum(firstobs=50) nowd spanrows missing;

   columns region subsidiary product sales;

   define region           / order ;

   define subsidiary       / order order=internal format=$fftot.;

   define product          / order order=internal format=$fftot.;

   define sales            / analysis;

   run;  

ods pdf close;

ods listing;

ScottBass
Rhodochrosite | Level 12

Hi Data,

I'm always amazed, not only at your actual SAS code, but at your thought process on how you approach a problem.  You usually come up with ways that make me go "D'oh" after I see them, but somehow escaped me until after your post.

Keep learning SAS 😉

Thanks,

Scott


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 3204 views
  • 3 likes
  • 2 in conversation