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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 935 views
  • 0 likes
  • 2 in conversation