Report:xxx Company Name Date : MMDDYYYY
code:xxx xxxxxxx page : 1
KIDSNAME SEX AGE
xxxxxx x xx More variables continue
xxxxxx x xx
KIDSNAME SEX AGE
xxxxxxxx x xx More variables continue
xxxxxxx x xx
I am trying to create the above report in PDF and each page should has page numbers like in the above layout.
The Report and code should be left side of the page and the company name should be in the center and date and page fileds should be right side of the page.
And in the last page the footnote should say " END".
We use proc report for most of the reports.
But for this report I am really lost and couldnt get any ides.
So, I would really appreciate any help.
Message was edited by: JasonNC
Message was edited by: JasonNC
What does your data look like???? This report probably -could- be done with PROC REPORT or it could be done with the pre-production DATA step interface to ODS (still experimental) or it might be able to be done with PUT _ODS_ statements.
It also depends on what destination you are interested in. You say you want PDF -- you could create this file using "classic" PUT statements with DATA _NULL_ and then distill the LISTING report manually to PDF using Adobe Acrobat or some 3rd party tool
For an idea of a possible approach with PROC REPORT, review the code and output below. Note that the report dataset was created directly with an INFILE statement -- you would have to take your data and manipulate it to be in a similar structure. It is the TYPE variable that determines what rows are shown in BOLD when the value of TYPE=HDR. The PGNUM, GRPNUM and LN_NUM variables are important because they ensure that all the "header" lines and "data" lines appear in the correct order. I only made 3 columns in the fake data and you could have more columns -- they would just need to be manipulated in the same way. I used an explicit PGNUM variable so that any "family" would not split across pages. That meant I had to create the report at least 1 time and visually inspect the report to see where the manual "break" needed to be.
Turning off the interior table lines with the STYLE override removes the interior lines; the NOHEADER option turns off all the TABLE headers, so it looks as though the fake headers in your data are the only headers there are; and the TITLE statements with J=L, J=C and J=R take care of the titles the way you want. ODS PDF TEXT= is used for the text string at the end of the report.
A variation of my program would still work. I see you changed the original posted version of the report. The key thing would be the data transformation from the structure of your original dataset to the structure needed for PROC REPORT code similar to mine. Your alternative is to investigate DATA _NULL_ with PUT statements. The thing is that there's different DATA _NULL_ syntax for LISTING output versus the DATA _NULL_ syntax for ODS output, such as PDF, RTF or HTML.
You say (above) that this is a representation of your input file:
Name ID Kidsname Sex Age
abc 100 x F 10
abc 100 y M 15
xyz 101 x F 11
xyz 102 y M 15
Are there any changes you want to make??? For example, why for person abc, is the ID (100) the same on both records??? But for person xyz, the ID is different (101 and 102) on both records. Is there a person ID -and- a kids ID?????
Does every family have exactly 2 kids??? Could there be a family without any kids? 1 kid?? 20 kids?? What would those records look like?? Is there an upper limit on the number of kids a family could have??? Are there any rules about splitting a family across a page??? Should a family always stay together???
To me, this looks like a fairly standard DATA step program using FIRST. and LAST. processing (depending on the complexity of the "family") observations. Your program would need to create multiple observations per "family". So if you were going to use my program sample, you would need one observation for the "NAME" line, a second observation for the "ID" line and a third observation for the "break" line -- I think that this would all happen on the FIRST.ID or FIRST.NAME observation. Then you'd need a fourth observation for the "KIDSNAME" header line, etc, etc. But without more information about the data (how many kids -- at least 1, always 2, up to 20) -- there's no point in writing a program until those facts about the data are known.
Does ANY number mean 0 kids??? What would the record look like if there were 0 kids????
abc 100 xenia F 10
abc 100 yorick M 15
xyz 101 anne F 11
xyz 101 bill M 15
def 102 ??? ? ?? <---no kids??
ghi 103 mary F 12 <---1 kid
That's good. Have you done much DATA step programming or used FIRST. or LAST. processing???? Do you know how the OUTPUT statement works?
For example, if you run the program below, you would get a dataset with 1 output observation for every input observation:
age_in_5 = age + 5;
ht_in_5 = height * 1.10;
proc print data=one_in_one_out;
title 'One Obs in, One Obs out -- show all 19 obs';
But in order to transform the data so you can use it with PROC REPORT (which means making your own pgnum, ln_num, col1, col2, etc variables -- as shown in my program), then you would have to output more than one observation for some of the observations in your input file.
So consider how this program will work:
data one_in_more_out(keep=name obsno type col1 col2);
length type $10 col1 col2 $25;
proc print data=one_in_more_out;
where name in ('Alfred', 'Alice', 'Barbara');
title 'One Obs in, One Obs out -- show only for 3 names';
When the above program runs, it will read through SASHELP.CLASS and output more than 1 observation for every student. The following PROC PRINT output shows what is in the output dataset for 3 of the names:
One Obs in, One Obs out -- show only for 3 names
Obs Name type col1 col2 obsno
1 Alfred hdr Name: Alfred 1
2 Alfred hdr Gender Height 1
3 Alfred data M 69.0 1
4 Alfred brk 1
5 Alice hdr Name: Alice 2
6 Alice hdr Gender Height 2
7 Alice data F 56.5 2
8 Alice brk 2
9 Barbara hdr Name: Barbara 3
10 Barbara hdr Gender Height 3
11 Barbara data F 65.3 3
12 Barbara brk 3
So if you compare the output above to what I originally posted as a possible program, you should start to get some idea of how you can produce the report you want with PROC REPORT.