BookmarkSubscribeRSS Feed
New_Bee
Calcite | Level 5

Can Proc Report produce the following output when the input data set is sashelp.class?

   
      Sex
---------------
   F       M
------- -------
Alice   Alfred
Barbara Henry
Carol   James
Jane    Jeffrey
Janet   John
Joyce   Philip
Judy    Robert
Louise  Ronald
Mary    Thomas
        William

10 REPLIES 10
Cynthia_sas
SAS Super FREQ

Hi:

  What is your destination of interest? HTML, RTF, PDF, LISTING? Are the ONLY variables on your report NAME and SEX? So you have ONLY character variables in your columns, you have nothing in the ROW area??

  The destination makes a difference? Both PDF and RTF have the COLUMNS= option that would allow you to create multiple columns of output. But there is a way to generate a report like this for HTML, RTF and PDF. But, can you explain why you would want to generate a report like this? Usually, PROC REPORT "needs" to have a GROUP or ORDER item before the first ACROSS item on the report. Your report doesn't have any GROUP or ORDER item. Or doesn't show one. And usually, PROC REPORT doesn't like to put a display item like NAME, under an ACROSS item, like SEX.

  Also, it doesn't look like you want to see a column header for NAME? Just a header for SEX and the values of each SEX?

cynthia

cynthia

New_Bee
Calcite | Level 5

Yes, the report should look exactly as shown and have sashelp.class as input.

Let me explain why I want to generate a report like this. This report is a simplified version of the sample report provided on page 33 of the ICH “Guideline for Industry” (http://www.fda.gov/downloads/regulatoryinformation/guidances/ucm129456.pdf) which lists adverse events of various severity and relatedness to the study drug by body system and visit (along with the summary information). Typically the structure of adverse events datasets is similar to that of sashelp.class.

I was thinking of LISTING destination. But are you suggesting that with the COLUMNS= option this can be done in RTF? Can you please
clarify (provide code?).

Thanks.

Cynthia_sas
SAS Super FREQ

Hi:

  When you say page 33, I don't see a table on page 33 -inside- that PDF file. See attached screenshot1. But on page 27 there is an adverse events table. This data does NOT look like the structure of SASHELP.CLASS...SASHELP.CLASS does NOT have the N(PCTN%) as an observation in the data. So there would have to be some summarizing to get this done. Plus, there are more than just NAMES in the Adverse Events report...Most reports such as that shown on page 27 are using ACROSS items in PROC REPORT.   So, yes, you can use PROC REPORT for what you want, but you'll probably need to do some data manipulation and summarizing instead of using your data directly.

  For this report, I would NOT recommend COLUMNS=2 -- but I have produced similar reports with PROC REPORT going directly to the RTF or PDF destinations. Take a look at some of these papers:

http://www2.sas.com/proceedings/sugi22/POSTERS/PAPER246.PDF

http://www.lexjansen.com/pharmasug/2009/cc/cc06.pdf

http://www2.sas.com/proceedings/sugi22/POSTERS/PAPER246.PDF

http://www.lexjansen.com/pharmasug/2011/sp/pharmasug-2011-sp07.pdf

http://analytics.ncsu.edu/sesug/2011/CC15.Zhang.pdf (really cool use of new feature)

http://www.nesug.org/proceedings/nesug08/ph/ph02.pdf

http://www2.sas.com/proceedings/sugi30/036-30.pdf

http://analytics.ncsu.edu/sesug/2010/PO09.Carty.pdf

http://www2.sas.com/proceedings/sugi31/052-31.pdf

  If that's not enough papers, you can go to www.lexjansen.com and search for more Adverse Event or related papers -- this web site has indexed all the PharmaSUG user group papers (as well as other SAS User Groups) . Generating clinical trial reports is a big topic at PharmaSUG.

Here's one last paper to read...look at Example 1 and Example 8: http://www2.sas.com/proceedings/forum2008/173-2008.pdf

cynthia


screenshot1_pg33.pngscreenshot2_pg27.png
New_Bee
Calcite | Level 5

Thanks for the following up. I’m actually not looking just for any Adverse Event or related papers. The papers you cited address different kinds of reports and don’t seem to be
relevant to my issue at all (including examples 1 and 8 of your paper).

What I am looking for is a code to produce this simple output (just two variables SEX and NAME) using Proc Report with the sashelp.class dataset as input. The problem is to put values of the same variable NAME coming from different observations of the class dataset on same line of the report e.g. Alice and Alfred. It is indeed similar to what COLUMN= option does, but not quite – the columns would have to have different headers e.g. F and M, respectively.

Are you saying you have done this without manipulating and summarizing the data outside of Proc Report? If you can show me how then I can show you how to produce the ICH report using the standard AE dataset as input.

Cynthia_sas
SAS Super FREQ

Hi:

  I'm confused, you referred to the Adverse Event report by page number. However, yes, I can produce the report. I need some "extra" helper variables to do it. So while I don't need to actually summarize sashelp.class, I do need to sort by SEX and then assign a simple ordering variable so that the first girl and first boy both get a value of 1 for the ordering var; the second girl and second boy both get 2 for the ordering var, etc. Then, because I want the NAME variable to be under the SEX variable, I have to have a single numeric variable on the report -- otherwise, PROC REPORT is not happy to put a character variable under an ACROSS item.

  The program below produced the attached screenshot. #1 shows all the "helper" variables and their column headers. #2 shows the report with NOPRINT for the helper variables. In order to show both reports in 1 screenshot, I didn't show all 19 obs in sashelp.class -- but you can remove that limit when you test.

  Depending on how much more you wanted to put on the report, I might be tempted to use a TABLE template and DATA _NULL_ program. Or maybe the new DATA step report object interface. But I can live with the helper variables and PROC REPORT to get this.

cynthia

proc sort data=sashelp.class out=class;

  by sex name;

run;

title;

   

data final;

  set class; by sex;

  where age ge 14;

  if first.sex then ordvar = 0;

  ordvar + 1;

run;

ods listing close;

    

ods rtf file='c:\temp\twocol.rtf' startpage=no;

ods pdf file='c:\temp\twocol.pdf' startpage=no;

ods html file='c:\temp\twocol.html';

 

** need to have "fakevar" -- a numeric variable;

** on the report, otherwise, PROC REPORT will not;

** do the ACROSS for a character variable.;

  

proc report data=final nowd;

  title '1) Show Helper Variables';

  column ordvar sex,name fakevar;

  define ordvar / group ;

  define sex / across ;

  define name / display 'Name';

  define fakevar / computed ;

  compute fakevar ;

    fakevar = 1;

  endcomp;

run;

 

proc report data=final nowd;

  title '2) Hide Helper Variables';

  column ordvar sex,name fakevar;

  define ordvar / group noprint;

  define sex / across ;

  define name / display ' ';

  define fakevar / computed noprint;

  compute fakevar ;

    fakevar = 1;

  endcomp;

run;

  

ods _all_ close;

title;


proc_report_two_col.png
New_Bee
Calcite | Level 5

Adding fakevar inside of proc report is fine, but ordvar is added outside of proc report which defeats my goal to avoid pre-processing the class dataset.

In some cases you don’t have to prepare your data to produce a report (e.g. proc report can produce a sorted output even if the input dataset is not sorted). Apparently that's not always the case, which my example seems to prove.

Anyway, thank you very much for your input – I really appreciate it.

New_Bee
Calcite | Level 5

That will work, but defeats my goal to avoid pre-processing the class dataset.

Anyway, thanks for your input - I really appreciate it,

Reeza
Super User

Does it have to be proc report or can it be another procedure, ie a single datastep or proc print/tabulate?

Ksharp
Super User

Here is a data step way, if you like it.

proc sort data=sashelp.class out=class;
  by sex name;
run;
proc sql noprint;
 select distinct sex into : sex separated by ' ' from class;
 select distinct catt('class(keep=sex name rename=(name=',trim(sex),') where=(sex="',trim(sex),'")) ') into : list separated by ' '  from class ;
quit;
data want;
 merge &list;
run;
ods listing close;
ods html file='c:\temp\twocol.html';
proc report data=want nowd;
column ('SEX' &sex);
run;
ods html close;
ods listing;


Ksharp

Ksharp
Super User

It is hard for REPORT .

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