BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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!
4 REPLIES 4
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
deleted_user
Not applicable
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!
deleted_user
Not applicable
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!
Deendayal
Calcite | Level 5
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.)

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 874 views
  • 0 likes
  • 3 in conversation