BookmarkSubscribeRSS Feed
draroda
Fluorite | Level 6

Dear All,

 

Can anyone please guide on how to handle only single subject data per page in proc report ?

 

Regards,

Rajesh

7 REPLIES 7
Tim_SAS
Barite | Level 11

Use the PAGE option on a BREAK AFTER statement.

draroda
Fluorite | Level 6

Hi Tom,

 

I have used that option and i am looking for alternate also where i can use some macro variables and populate the subject id in the header part/title of page.

draroda
Fluorite | Level 6

Hi, 

 

I used below but not  working as per my requirement.

 

data a;
input x $ score ;
datalines;
a 1
a 2
a .
a 3
a 4
b .
b 4
b 4
b 6
b .
;

 


proc sql;
create table aa as select distinct x from a;
select distinct x into :n_1-:n_&sqlobs from a;
quit;
%let N = &sqlobs;
%macro headache;
%do i=1 %to &N;
%put &&n_&i;
proc sql;
create table report as select score from a where x="&&n_&i";
quit;
data re;
set report;
sn+1;
run;
title "report for &&n_&i";
ODS PDF FILE="D:\Practice\test.pdf";
proc report data=re nowd;
column sn score;
define sn /order ;
define score/style(column)={just=left};
run;
ods _all_ close;
%end;
%mend;
%headache;

 

So ideally this should print two pages in output but it print only single page and that is for last subject only.

 

I have observed that macro is overwriting the observations.Please guide.

draroda
Fluorite | Level 6

Hi,

 

Can anyone please guide and tweak the attached code for me.

 

In this, Proc report is overwriting previous subject observation and poduce only one page.

 

I need two page in that report

Tim_SAS
Barite | Level 11

In your macro, the statement

ODS PDF FILE="D:\Practice\test.pdf"

recreates test.pdf every time the macro is called. That means each time you call the macro the macro overwrites the previous version of the file. Remove this statement from your macro and put it just before you run the macro.

draroda
Fluorite | Level 6
Thanks Tom,

I have placed the same outside macro but now it write only first observation .

I also tried to place it inside macro but before do loop and it writes last observatioon .
ballardw
Super User

You may want to look at BY processing with the #BYLINE and #BYVAL to modify the title.

 

 

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