BookmarkSubscribeRSS Feed
anu
Fluorite | Level 6 anu
Fluorite | Level 6

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,

10 REPLIES 10
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

data_null__
Jade | Level 19

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

anu
Fluorite | Level 6 anu
Fluorite | Level 6

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?

data_null__
Jade | Level 19

What is the output destination?

anu
Fluorite | Level 6 anu
Fluorite | Level 6

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

data_null__
Jade | Level 19

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.

Ksharp
Super User

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

Cynthia_sas
SAS Super FREQ

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
Ksharp
Super User

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

anu
Fluorite | Level 6 anu
Fluorite | Level 6

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.

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!

How to Concatenate Values

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.

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
  • 10 replies
  • 1812 views
  • 0 likes
  • 5 in conversation