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;

z.png

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