ODS and Base Reporting

Build reports by using ODS to create HTML, PDF, RTF, Excel, text reports and more!
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
twildone
Pyrite | Level 9

Hi,

 

I am trying to create a report using ods pdf proc report and separating the dataset into separate tables on different pages using "BY Customer_Number". This part works fine. The problem I am having is that I would like extract the appropriate Customer_Number, Name and Address and placing these corresponding values in the title on each page that represent the appropriate data results. The dataset that I using for the report is similiar to the one below:

 

Customer_Number

Name

Address

Item_Number

Sale_Price

1654

Smith J.

123 Lowe

23127687

100.34

1654

Smith J.

123 Lowe

32146745

54.35

1721

Anderson B.

34 Buffalo

11450955

37.89

1922

Rae S.

6709 Mayfair

78663456

115.78

 

 

I would like the pdf file to look like the following where the first row is actually the title:

 

1654

Smith J.

123 Lowe

 

Item_Number

Sale_Price

 

23127687

100.34

 

32146745

54.35

 

 

1721

Anderson B.

34 Buffalo

 

Item_Number

Sale_Price

 

11450955

37.89

 

 

1922

Rae S.

6709 Mayfair

 

Item_Number

Sale_Price

 

78663456

115.78

 

I wonder if someone can help...thanks...

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ
Well, you don't show your BY statement -- are the data sorted by all 3 BY variables? In order to use #BYVAL you either use the syntax #BYVAL(varname) or #BYVAL1, #BYVAL2. I believe if you are going to use the numbers as reference, you don't use parens with the number form. Check the doc.

cynthia

View solution in original post

4 REPLIES 4
Cynthia_sas
SAS Super FREQ
Hi:
Look up the use of #BYVAR and #BYVAL special syntax commands, which are ways for you to use BY variables in the TITLE statement on your reports from many different procedures (not just PROC REPORT). I believe there have been previous postings on the use of #BYVAR and #BYVAL and I know there are examples in the documentation. So it should be fairly easy to find.

cynthia
twildone
Pyrite | Level 9
Hi Cynthia, I may not have been clear to exactly what I was hoping to achieve. I was hoping that I would be able to Call these BY Values into a title statement such as in title statement TITLE3 in the following: TITLE1 JUSTIFY=CENTER BOLD HEIGHT=12PT FONT="Arial" "Listing of Sales"; TITLE2 " "; TITLE3 JUSTIFY=LEFT HEIGHT=9PT FONT=Arial "Customer Number: #BYVAL(1)" JUSTIFY=CENTER "Name: #BYVAL(2)" JUSTIFY=RIGHT "Address: #BYVAL(3)"; TITLE4 " "; TITLE5 "^{style[bordertopwidth=2px bordertopcolor=black] &tstr}";
Cynthia_sas
SAS Super FREQ
Well, you don't show your BY statement -- are the data sorted by all 3 BY variables? In order to use #BYVAL you either use the syntax #BYVAL(varname) or #BYVAL1, #BYVAL2. I believe if you are going to use the numbers as reference, you don't use parens with the number form. Check the doc.

cynthia
Ksharp
Super User
You'd better post a picture to display what output you need . What is your output destination ? PDF RTF ?
data have;
input (Customer_Number Name Address) (&$20.) Item_Number Sale_Price ;
cards;
1654  Smith J.  123 Lowe  23127687  100.34
1654  Smith J.  123 Lowe  32146745  54.35
1721  Anderson B.  34 Buffalo  11450955  37.89
1922  Rae S.  6709 Mayfair  78663456  115.78
;
run;

proc report data=have nowd noheader;
column Customer_Number Name Address dummy Item_Number Sale_Price;
define Customer_Number /order noprint;
define Name /order noprint;
define Address /order noprint;
define dummy/computed ;
compute dummy/char length=10;
 dummy=' ';
endcomp;
compute before Address ;
 line @1 Customer_Number $20. +4 Name $20. +4 Address $20. ;
 line @22 "Item_Number" +20 "Sale_Price";
endcomp;
quit;

undefined

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 2165 views
  • 0 likes
  • 3 in conversation