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

Hi there,

I need help to output file in pdf format with a Title that correspondence to the ID.

I have 2 tables:

table 1:

ID VISIT LAB
10 1 YES
10 2 NO
10 3 NO
20 2 YES
20 3 YES
20 5 NO
20 6 NO

 

table 2:

ID GENDER
10 FEMALE
20 MALE

 

I want the pdf output as following (page 1, page2 etc..)

PAGE 1 look like this:

 

GENDER: FEMALE

ID

VISIT

LAB

10

1

YES

10

2

NO

10

3

NO

 

PAGE2:

 

GENDER: MALE

ID

VISIT

LAB

20

2

YES

20

3

YES

20

5

NO

20

6

NO

 

How to code(link) the 2 tables into one output?

 

Thank you in advance, really appreciate your time.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

Like this?

data TABLE1;
input ID VISIT LAB $3.;
cards;
10 1 YES
10 2 NO 
10 3 NO 
20 2 YES
20 3 YES
20 5 NO 
20 6 NO 
run; 

data TABLE2;
input ID GENDER $6.;
cards;
10 FEMALE
20 MALE  
run;                                                      

proc sql;
  create table REPORT as select * from TABLE1, TABLE2 where TABLE1.ID=TABLE2.ID order by ID;
quit;
                                      
ods pdf file="&wdir\t.pdf" startpage=bygroup notoc;
proc print data=REPORT noobs; by GENDER; *title2 'GENDER:#byval1'; var ID VISIT LAB; run;
ods pdf close;

ChrisNZ_0-1627723767930.png

 

 

View solution in original post

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

Like this?

data TABLE1;
input ID VISIT LAB $3.;
cards;
10 1 YES
10 2 NO 
10 3 NO 
20 2 YES
20 3 YES
20 5 NO 
20 6 NO 
run; 

data TABLE2;
input ID GENDER $6.;
cards;
10 FEMALE
20 MALE  
run;                                                      

proc sql;
  create table REPORT as select * from TABLE1, TABLE2 where TABLE1.ID=TABLE2.ID order by ID;
quit;
                                      
ods pdf file="&wdir\t.pdf" startpage=bygroup notoc;
proc print data=REPORT noobs; by GENDER; *title2 'GENDER:#byval1'; var ID VISIT LAB; run;
ods pdf close;

ChrisNZ_0-1627723767930.png

 

 

ursula
Pyrite | Level 9

Thank you so much for your help!

it's exactly of what I expected.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 686 views
  • 3 likes
  • 2 in conversation