BookmarkSubscribeRSS Feed
dash
Obsidian | Level 7
Hi all,

How can I report the below data state wise (AP KA TN) in two pages in stead of three; AP and KA data should be in one page and TN data in another page.
plz check. I have written the program like that.(displaying in three separate pages)
data prod_sales;
input state $ pcode $ area $ month stock sale;
cards;
AP N79 HYD 1 40 20
TN N79 CHN 1 30 10
KA N79 BAN 1 45 20
AP N79 HYD 2 30 15
TN N79 CHN 2 10 10
KA N79 BAN 2 45 30
TN N79 CHN 3 20 10
KA N79 BAN 3 25 20
AP N79 HYD 3 20 15
;
proc report data=prod_sales nowd headline;
define state/order;
define area/order;
define pcode/order;
break after state/page;
compute after state;
line 65*'-';
line 'End of the report';
endcomp;
compute before _page_;
line 'This report belongs to: ' state $6.;
endcomp;
run;

Thanks in advance
3 REPLIES 3
Ksharp
Super User
Hi.
Because of ' break after state/page;' ,You have three value so have three pages.
Want two page is easy to make a break variable.



[pre]
data prod_sales;
input state $ pcode $ area $ month stock sale;
if state='TN' then page=1;
else page=0;
cards;
AP N79 HYD 1 40 20
TN N79 CHN 1 30 10
KA N79 BAN 1 45 20
AP N79 HYD 2 30 15
TN N79 CHN 2 10 10
KA N79 BAN 2 45 30
TN N79 CHN 3 20 10
KA N79 BAN 3 25 20
AP N79 HYD 3 20 15
;
ods pdf file='c:\test.pdf' style=sasweb;
proc report data=prod_sales nowd headline;
column page state area pcode;
define page /group noprint;
define state/order;
define area/order;
define pcode/order;
break after page/page;
compute after state;
line 65*'-';
line 'End of the report';
endcomp;
compute before _page_;
line 'This report belongs to: ' state $6.;
endcomp;
run;
ods pdf close;


[/pre]
deleted_user
Not applicable
hello,

I will add to KSharp's solution the use of proc format so the title changes a little bit:

[pre]
data prod_sales;
input state $ pcode $ area $ month stock sale;

s=ifn(state in ('AP','KA'),1,2);

cards;
AP N79 HYD 1 40 20
TN N79 CHN 1 30 10
KA N79 BAN 1 45 20
AP N79 HYD 2 30 15
TN N79 CHN 2 10 10
KA N79 BAN 2 45 30
TN N79 CHN 3 20 10
KA N79 BAN 3 25 20
AP N79 HYD 3 20 15
;

proc format;
value s
1='AP,KA'
2='TN';
run;

proc report data=prod_sales nowd headline;

column s state pcode area month stock sale;

define state/order;
define area/order;
define pcode/order;
define s/group noprint;

break after state/summarize;

break after s/page;

compute after s;
line 65*'-';
line 'End of the report';
endcomp;

compute before _page_;
line 'This report belongs to: ' s s.;
endcomp;

run;
[/pre]

Marius
dash
Obsidian | Level 7
Thanks!!!!!!!!! Its running

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 751 views
  • 0 likes
  • 3 in conversation