Help using Base SAS procedures

Producing a report for each record

Reply
N/A
Posts: 0

Producing a report for each record

I posted this question in the DATA step forum, but I think it might belong here.

I produce a weekly SAS data set for which I would like to print one record per page for the staff member who will be using it. I'd like it to look something like this:

Page 1:
ID #:
XXXXXX
Name:
XXXXX, XXX
City:
XXXXXXXX

Page 2:
ID #:
YYYYYYY
Name:
YYYYY, YYY
City:
YYYYY

I know I can use the Reports function in Microsoft Access or Mail Merge in MS Word, but is there a way to get SAS to do this? I tried using PROC PRINT with a BY statement. However, the staff member specifically asked for it not to be a line listing, and I haven't been able to get PROC PRINT to give me anything else.

Thanks!
Super Contributor
Super Contributor
Posts: 3,174

Re: Producing a report for each record

Posted in reply to deleted_user
DATA step or likely PROC REPORT can do this for you - doubt you can get PROC PRINT to go vertical with variables, easily.

Explain more about what type of output destination you are generating - suggest sharing whatever code you have related to the rqmt.

Scott Barry
SBBWorks, Inc.
N/A
Posts: 0

Re: Producing a report for each record

Thanks everyone for the help so far!

I am working with electronic laboratory reports for infectious disease surveillance. I wrote a SAS program that goes through all the lab reports and keeps only the ones we need. When it is done, I have lists of tests to send to other databases. It looks something like this when I use PROC PRINT or export it to an Excel file:

ID# LName FName TestDate TestResult
12356 Doe John 06/31/2013 Positive
98895 Doe Jane 04/31/2013 Positive

Some of the tests must be entered by hand into their final destinations. The staff member who is responsible for this does not like the format above. I tried this:

proc sort data=updates;
by id;
run;

ods pdf file='L:\elr\updates_20100329.pdf;
proc print data=updates noobs;
by id;
title 'ELR Updates';
run;
ods pdf close;

This would work if I could figure out a way to control where each field went, like this:

LName FName
Doe John

TestDate TestResult
06/31/2013 Positive

I'll play around with it more and welcome any further suggestions. Thanks again!
N/A
Posts: 0

Re: Producing a report for each record

Posted in reply to deleted_user
I posted an answer to this in your other thread. You could use ODS to put the output into Excel, which strikes me as much easier to work with than pdf.

It would help if you would specify the exact format desired; in your other post you didn't. You could still use the approach there, using the "header" file statement option and n=ps;

It would help if you elaborated "other databases." Enter by hand?! Anathema.

Jonathan


> Thanks everyone for the help so far!
>
> I am working with electronic laboratory reports for
> infectious disease surveillance. I wrote a SAS
> program that goes through all the lab reports and
> keeps only the ones we need. When it is done, I have
> lists of tests to send to other databases. It looks
> something like this when I use PROC PRINT or export
> it to an Excel file:
>
> ID# LName FName TestDate
> TestResult
> Doe John 06/31/2013
> Positive
> Doe Jane 04/31/2013
> Positive
> of the tests must be entered by hand into their
> final destinations. The staff member who is
> responsible for this does not like the format above.
> I tried this:
> proc sort data=updates;
> by id;
> run;
>
> ods pdf file='L:\elr\updates_20100329.pdf;
> proc print data=updates noobs;
> by id;
> title 'ELR Updates';
> run;
> ods pdf close;
>
> This would work if I could figure out a way to
> control where each field went, like this:
>
> LName FName
> Doe John
>
> TestDate TestResult
> 06/31/2013 Positive
>
> I'll play around with it more and welcome any further
> suggestions. Thanks again!
New Contributor
Posts: 2

Re: Producing a report for each record

Posted in reply to deleted_user
Hi

If I understand your requirement correctly. Please use below logic. I took an example as per your posting.

Note: Last put statement may not be efficient logic but you can use this logic as per your requirements.


data ddprint;
infile datalines;
input id Name $ City $;
datalines;
111 Name1 City1
222 Name2 City2
333 Name3 City3
444 Name4 City4
555 Name5 City5
666 Name6 City6
;
Filename pr "";
options pagesize=1;
data _null_;
set ddprint;
by id;
file pr N=1;
put id =;
put Name=;
put City= ;
put //////////////;
run;


let me know if you need any other inputs.

Thanks,
Deendayal Cheni
Oracle Corporation (Formerly: Sun Microsystems Inc.)
Ask a Question
Discussion stats
  • 4 replies
  • 152 views
  • 0 likes
  • 3 in conversation