BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ANKH1
Pyrite | Level 9

The table produced has many columns. Is there a way to display a pdf where the first 4 columns are repeated in all pages? There are many more columns after position and many more rows. I have the following code but it is not working:

data sample;
input ID $ Name $ Age Salary Department $ Position $;
datalines;
1 John 30 50000 HR Manager
2 Jane 25 55000 Finance Analyst
3 Jack 40 60000 IT Developer
4 Jill 35 62000 Marketing Specialist
;
run;

ods pdf file='C:\path\to\your\output.pdf';

proc report data=sample nowd split='_';
    column ID Name Age Salary Department Position;
    define ID / 'ID' left;
    define Name / 'Name' left;
    define Age / 'Age' center;
    define Salary / 'Salary' right;
    define Department / 'Department' left;
    define Position / 'Position' left;
    
    /* Specify the columns to be repeated */
    compute after _page_;
        line ' ';
        line 'ID     Name     Age     Salary';
    endcomp;
run;

/* Close ODS PDF destination */
ods pdf close;
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Using ID + PAGE option :

 

data sample;
input ID $ Name $ Age Salary Department $ Position $;
datalines;
1 John 30 50000 HR Manager
2 Jane 25 55000 Finance Analyst
3 Jack 40 60000 IT Developer
4 Jill 35 62000 Marketing Specialist
;
run;

ods pdf file='C:\temp\output.pdf';

proc report data=sample nowd split='_';
    column ID Name Age Salary Department Position;
    define ID / 'ID' left   ;
    define Name / 'Name' left  ID ;
    define Age / 'Age' center;
    define Salary / 'Salary' right;
    define Department / 'Department' left PAGE;
    define Position / 'Position' left;
    
    /* Specify the columns to be repeated */
    compute after _page_;
        line ' ';
        line 'ID     Name     Age     Salary';
    endcomp;
run;

/* Close ODS PDF destination */
ods pdf close;

View solution in original post

2 REPLIES 2
Ksharp
Super User

Using ID + PAGE option :

 

data sample;
input ID $ Name $ Age Salary Department $ Position $;
datalines;
1 John 30 50000 HR Manager
2 Jane 25 55000 Finance Analyst
3 Jack 40 60000 IT Developer
4 Jill 35 62000 Marketing Specialist
;
run;

ods pdf file='C:\temp\output.pdf';

proc report data=sample nowd split='_';
    column ID Name Age Salary Department Position;
    define ID / 'ID' left   ;
    define Name / 'Name' left  ID ;
    define Age / 'Age' center;
    define Salary / 'Salary' right;
    define Department / 'Department' left PAGE;
    define Position / 'Position' left;
    
    /* Specify the columns to be repeated */
    compute after _page_;
        line ' ';
        line 'ID     Name     Age     Salary';
    endcomp;
run;

/* Close ODS PDF destination */
ods pdf close;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 243 views
  • 0 likes
  • 2 in conversation