The SAS Output Delivery System and reporting techniques

Report Display

Reply
Contributor anu
Contributor
Posts: 23

Report Display

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:

ID123NameABCSexM
Age12Weight83Height58
Hobbywatching movies

Table2:

ID123SchoolXYZCityNew York
StateNYCountyZip00000
Extra ActivitiesArt Clubs

Anu,

Super User
Super User
Posts: 7,407

Re: Report Display

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.

Respected Advisor
Posts: 3,777

Re: Report Display

Why don't you try the PROC REPORT statement option NAMED and see if that will be adequate.

Contributor anu
Contributor
Posts: 23

Re: Report Display

Thanks data _null_. See the sample file, Report_example.PNG

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?

Respected Advisor
Posts: 3,777

Re: Report Display

What is the output destination?

Contributor anu
Contributor
Posts: 23

Re: Report Display

Would need this as WORD or PDF. The Table1 in the sample was created using ODS RTF.

Respected Advisor
Posts: 3,777

Re: Report Display

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.

Super User
Posts: 9,682

Re: Report Display

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

SAS Super FREQ
Posts: 8,743

Re: Report Display

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;


mult_cols_mult_rows_per_obs.png
Super User
Posts: 9,682

Re: Report Display

I can't agree with you any more. Reshape the dataset is best way for such question.

Contributor anu
Contributor
Posts: 23

Re: Report Display

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.

Ask a Question
Discussion stats
  • 10 replies
  • 791 views
  • 0 likes
  • 5 in conversation