Hi everyone,
I posted this question in SAS Procedures and was told to re-post here. I am looking to create either a word or pdf file but need the data displayed in the below format. Can Proc Report do something like the below?
I have multiple block of data that will need to go on the same page by ID. For example
Table1:
ID | 123 | Name | ABC | Sex | M |
Age | 12 | Weight | 83 | Height | 58 |
Hobby | watching movies |
Table2:
ID | 123 | School | XYZ | City | New York |
State | NY | County | Zip | 00000 | |
Extra Activities | Art Clubs |
Anu,
Well, numerous ways I can think of doing it:
data _null_ with a file statement and put each item, variable. Can get exactly what you want, bit tedious.
create a dataset which looks like your output eg:
COL1 COL2 COL3
ID 123 Name ...
Age 12 Weight ...
Then proc report that.
They would be my suggestions.
Why don't you try the PROC REPORT statement option NAMED and see if that will be adequate.
Thanks data _null_. See the sample file,
The data is displayed like in the first table with Sector=Southwest in RTF file.
I need it displayed similar to Table 2. Any thoughts if this can be done?
What is the output destination?
Would need this as WORD or PDF. The Table1 in the sample was created using ODS RTF.
You need to include a "good" example of your input (starting point) data. Also include a working data step to read it or attach a SAS data set.
OK. Give you some example code. Hope help you a little bit .I am wondering where is Cynthia ?
data class ; set sashelp.class; run; ods listing close; ods pdf file='want.pdf' style=sasweb ; proc report data=class nowd noheader style(report)={just=center rules=none frame=void outputwidth=100%}; columns name sex age weight height; define name/order noprint; define sex/order noprint; define age/order noprint; define weight/order noprint; define height/order noprint; compute after height; line @1 'Name:' name $14. @20 'sex:' sex $2. @25 'age' age; line @1 'Weight:' weight @20 'height:' height; endcomp; run; ods listing ;
Xia Keshan
Hi:
I agree with data_null_ -- all we've seen so far is the "post-processed" screen shots of what the original poster says he/she wants. There has not been any real DATA shown or provided. The screen shot showed 2 very different types of output. And it wasn't clear to me why the second screen shot showed color coding unless it was an example of the desired output or a second dataset.
My tendency is to go with the approach suggested by RW9 -- when dealing with non-LISTING destinations, like RTF or PDF, I tend to avoid the use of the LINE statement approach, especially since there are no "cells" and therefore, no color coding that can be applied to specific cells (like Manager and Department in blue background and the values in white background). In addition, with the LINE statement and ODS RTF, or ODS PDF, the output doesn't "line up" because the @1, @20, @25, etc are fairly meaningless when dealing with proportional spaced fonts.
The program below created the output shown in the screen shot. But, without data from the original poster, it is impossible to tell whether the data is in a form to be used in a program like this. For example, if the data for the report are in 2 separate files, instead of 1 file, then there is some more data manipulation that will need to be performed before the report can be created.
Cynthia
data class ;
length col1 col2 col3 col4 col5 col6 $15;
set sashelp.class;
where name in ('Alfred', 'Alice', 'Barbara', 'John');
obsno = _n_;
ordno = 1;
col1 = 'Name: ';
col2 = name;
col3 = 'Sex: ';
col4 = sex;
col5 = 'Age: ';
col6 = put(age,2.0);
output;
ordno + 1;
col1 = 'Height: ';
col2 = put(height,4.1);
col3 = 'Weight: ';
col4 = put(weight,4.1);
col5 = ' ';
col6 = ' ';
output;
run;
ods _all_ close;
ods pdf file='c:\temp\desired.pdf' style=sasweb ;
proc report data=class nowd noheader
style(report)={just=center rules=none frame=void cellspacing=0}
style(column)={just=c};
columns obsno ordno col1 col2 col3 col4 col5 col6;
define obsno/order noprint;
define ordno/order noprint;
define col1/display style(column)={font_weight=bold background=lightblue };
define col2/display ;
define col3/display style(column)={font_weight=bold background=lightblue };
define col4/display ;
define col5/display style(column)={font_weight=bold background=lightblue };
define col6/display ;
compute after obsno;
line ' ';
endcomp;
run;
ods pdf close;
I can't agree with you any more. Reshape the dataset is best way for such question.
Thanks very much for all your feedback.
Data comes from many different excel files. I am in the process of data manipulation. Color Coding is not a requirement at the moment and the output choice is PDF. I will take your points into consideration and reshape the dataset.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.