The SAS Output Delivery System and reporting techniques

Text above columns in proc report

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 119
Accepted Solution

Text above columns in proc report

[ Edited ]

Hello,

 

Does anyone know how to use proc report and get text outside of the table?  The output needs to (vaguely) look like this:


PATIENTS: Patient Profile
Contains one record per patient in the database, and gives basic demographic and related data.


Variable         Type     Length     Format             Comment
ADRIND             num         8                                 This patient is included in the cohort
ADRINDTXT     char         1         $ADRINDT.     Reason this patient was not included in the cohort
BORN                 num         8         MMDDYY10.     Date of Birth

[blah blah more meta data...]

 

************************

I have the table grid worked out, but not the text above it, which is three variables:

[name] : [Desc1]

[Desc2]

 

Here's the code i have so far:

ods listing close;
ods pdf file="&path.AppendixB.pdf";
proc report data=Formats3 nowd headline headskip wrap center;
    column name desc1 desc2 variable type length format comment;
    define variable / width=12 "Variable";
    define type     / width=9 "Type";
    define length    / width=16 "Length";
    define format    / width=254 "Format";
    define comment    / width=254 "Comment";
run;
ods pdf close;

 

Thanks

Megan

 

 

 


Accepted Solutions
Solution
‎04-07-2016 11:45 AM
Frequent Contributor
Posts: 119

Re: Text above columns in proc report

I really don't understand why no one seems to understand what my data source is or how i want the report to look.  I thank you all for trying, i really do.  But i'm closing this post.  It's not helping at this point.

 

 

View solution in original post


All Replies
Grand Advisor
Posts: 10,211

Re: Text above columns in proc report

From your post I can't tell whether you want Proc Contents output as part of your report or not. Could you post an example of what you actually want this to look like. Dummy data is fine but since your question involves layout issues then we need an actual layout. An example dataset would also help to test code.

 

Also are the values you indicate with :

[name] : [Desc1]

[Desc2]

 

It may be that By group processing with Name Desc1 and Desc2 would work as there are some controls available for by values.

 

 

Frequent Contributor
Posts: 119

Re: Text above columns in proc report

I did post what i want it to look like:

Using variable names, it's:

[name]: [desc1]

[desc2]

 

(HeadersSmiley Happy Variable         Type     Length     Format          Comment
                [Variable]        [Type]   [Length]    [Format]        [Comment]

 

Output looks like:

PATIENTS: Patient Profile
Contains one record per patient in the database, and gives basic demographic and related data.


Variable         Type     Length     Format             Comment
ADRIND             num         8                                 This patient is included in the cohort
ADRINDTXT     char         1         $ADRINDT.     Reason this patient was not included in the cohort
BORN                 num         8         MMDDYY10.     Date of Birth

[blah blah more meta data...]

Frequent Contributor
Posts: 119

Re: Text above columns in proc report

Maybe proc report isn't the way to go??

Super Contributor
Posts: 394

Re: Text above columns in proc report

Couple of thoughts...

  1. Use LINE statements in a COMPUTE BEFORE block.
  2. Use ODS TEXT= or PROC ODSTEXT to create the text above.
  3. Create two PROC REPORT tables, the first one with the text above. Use ODS LAYOUT to print the tables with no space between them. You'll have to use some care to make both tables the same width.

Also, those WIDTH= options don't work when you're creating PDF output. Instead, use the WIDTH= style attribute in a STYLE= option on the DEFINE statements.

Frequent Contributor
Posts: 119

Re: Text above columns in proc report

Thanks, but it doesn't look like i can use variable names in the text.

 

I have three fields:

Name - dataset name

Desc1 - a short description of the dataset.

Desc2 - a longer description of the dataset.

 

I need the content of those three fields above each of the tables.

 

And thanks/sorry, but i have about 5 minutes experience with proc report.  I don't know how to do a compute block or line statement or where to even put them in the code that i already have.

 

I just need to display the contents one dataset that contains table description information and proc contents info.  And it's not looking like proc report is the best way for me to do it.

Grand Advisor
Posts: 9,578

Re: Text above columns in proc report

Not sure. What kind of report are you looking for ? Post a picture to display it .
Maybe you need NAMED option :


proc report data=Formats3 nowd headline headskip wrap center   named  ;


Frequent Contributor
Posts: 119

Re: Text above columns in proc report

This is the current output.  I created it through a data null with put statements.  *If* it can be done through proc report, it might be easier.  The put statements and word wrapping and junk is a p.i.t.a.

 

I'm trying to attach a photo.  The words in red are the variable names from the dataset.

 

I can get variable, type, length, format, and comment through proc report, but i cannot get category, name, desc1, or desc2 in those positions.

 

 

 

Attachment
Grand Advisor
Posts: 10,211

Re: Text above columns in proc report

Here is an approach that might help. Since the key bit appears to be that you have the name and descriptions about a data set in another set the code below:

1) creates an example data set to work with

2) creates a control dataset with some of the elements you describe

3) uses the control dataset to put the header elements before table output using Call Execute

4) uses existing SAS maintained meta data to extract the remainder of the data elements.

 

This approach would probably work best if your "comment" field actually is assigned as the variable label.

 

Data work.class;
   set SASHELP.Class;
   format age f2. height 4.1 weight 5.1 Sex $1. Name $10.; 
   Label 
      Age='Age at measure'
      Height='Height in inches'
      weight='Weight in pounds'
      Sex = 'Gender'
      Name= 'Student name'
   ;
run;
   

data RepControl;
   informat dsname $32. libname $8. desc1 desc2 category $50.;
   infile datalines dlm=',';
   input dsname libname desc1 desc2 category;
   dsname=upcase(dsname);
   libname=upcase(libname);
datalines;
CLASS,Work,Student height and weight,Contains one record per student, Example Data
;
run;


ods pdf file="c:\somepath\trial.pdf";
data _null_;
   set RepControl;
   length str $ 200;
   str= catx('"',"ODS Text=",Category,";");
   Call Execute(str);

   str = catx(": ",Dsname,Desc1);
   str= catx('"',"ODS Text=",Str,";");
   Call Execute(str);

   str=catx('"',"ODS Text=",Desc2,";");
   Call Execute(str);
   Call Execute("Proc sql;");
   Call Execute("   select Name Label='Variable',Type Label='Type',Length label='Length',");
   Call Execute("          format Label='Format',Label Label='Comment'");
   Call Execute("   from dictionary.columns");
   str = cats('      where libname="',libname,'" and memname="',dsname,'"');
   Call Execute(str);
   call Execute("   order by Name;");
   call execute("quit;");
run;
ods pdf close;

Solution
‎04-07-2016 11:45 AM
Frequent Contributor
Posts: 119

Re: Text above columns in proc report

I really don't understand why no one seems to understand what my data source is or how i want the report to look.  I thank you all for trying, i really do.  But i'm closing this post.  It's not helping at this point.

 

 

Grand Advisor
Posts: 10,211

Re: Text above columns in proc report

 
Grand Advisor
Posts: 10,211

Re: Text above columns in proc report


MeganE wrote:

I really don't understand why no one seems to understand what my data source is or how i want the report to look.  I thank you all for trying, i really do.  But i'm closing this post.  It's not helping at this point.

 

 


1) You did not post DATA we could test anything with so it is somewhat difficult to see what you are starting with

2) You show what appears to be the same item appearing multiple times and did not seem to understand we were trying to get clarification of the requirement

 

Frequent Contributor
Posts: 119

Re: Text above columns in proc report

I posted a screen shot of the output with the data and variable names in red right there.  I'll attach it again for you.

 

But I think that's part of the problem.  I think people are assuming that "patient profile" is code for someone's name, but it's not.  That the fields listed under variable actually contain data, but they ARE the data.  The screenshot is verbatim what is in my dataset that i need to show up.  It's one dataset with proc contents meta data for about 50+ tables.

 

I have one dataset with 9 fields in it and i need to place them all in a single report.  That's it.

 

I don't see where "the same item appearing multiple times" is.  I have 9 fields all with unique names.

Attachment
SAS Super FREQ
Posts: 8,720

Re: Text above columns in proc report

Hi, In addition to BallardW's suggestion just a few comments -- headline, headskip, wrap and width= are ignored by PDF, as they are LISTING only syntax.

In addition, generally for what you describe (a TABLE for each patient), many people would use COMPUTE BEFORE _PAGE_ as an alternative to BY group processing. I believe there are some previous postings that show the use of both methods of getting extra information on the report.

cynthia
Frequent Contributor
Posts: 119

Re: Text above columns in proc report

Thanks, but i don't have the necessary foundation in proc report in order to be able to adapt code written for something else, for what i need to do.
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 17 replies
  • 751 views
  • 0 likes
  • 5 in conversation