Jane Eslinger

4月 182017
 

Ok, so you know how to create multiple sheets in Excel, but can anyone tell me how to control the name of the sheets when they are all created at once? In the ODS destination for Excel, the suboption SHEET_INTERVAL is set to TABLE by default.  So what does that [...]

The post How to control the name of Excel sheets when they are all created at once appeared first on SAS Learning Post.

4月 072016
 

When you’re making a report, how do you choose which procedure to use?  The answer is – it depends. It depends on: whether you are doing an ad hoc analysis or creating a final report that many people will see whether you will run statistical tests with your data or […]

The post PROC REPORT versus other base SAS procedures appeared first on SAS Learning Post.

7月 112014
 

Did you inherit code that was written eons ago?  Do you find old programs to copy the PROC REPORT code and then simply change the variable names for your new program?  Have you wondered what all of those options do?  Do you ever send output to the Listing destination (the Output Window) anymore?

If you said yes to any of the questions above -- clean it up!  PROC REPORT has been around forever, but it has changed and evolved over the years to facilitate the creation of nicer looking output, specifically in non-Listing ODS destinations.

There are a number of options that are only valid in the Listing destination. Do you really need them? If you aren’t using that destination, then remove any outdated options from your SAS programs. Here’s a list by statement in the REPORT procedure:

PROC REPORT statement: outdated options

BOX NOWD/NOFS *
COLWIDTH= PANELS=
FORMCHAR= PS=
HEADLINE PSPACE=
HEADSKIP SPACING=
LS= WRAP

Nonwindowing mode became default in 9.4.

DEFINE statement: outdated options

CENTER * RIGHT *
FLOW SPACING=
LEFT * WIDTH= **

* In the Listing destination the LEFT, RIGHT, and CENTER options change the justification of both the headers and the data.  In other ODS destinations these options change only the justification for the data.  Instead of these options, it is highly recommended that you use the JUST= attribute within STYLE(COLUMN)= and STYLE(HEADER)= to change the justification.

** The standalone WIDTH= option is for Listing.  WIDTH= within a style specification, like STYLE(COLUMN)=[WIDTH=1IN], is for other ODS destinations.

BREAK statement: outdated options

DOL SKIP
DUL UL
OL

RBREAK statement: outdated options

DOL SKIP
DUL UL
OL

You can leave these options in, but why?  Make your PROC REPORT code more readable for yourself and anyone else who picks it up.  

 

tags: Problem Solvers, PROC REPORT, SAS Programmers
3月 142014
 

Like every SAS procedure, PROC REPORT generates error messages that are specific to that procedure.  Some of these errors are easier to understand and work around than others.  In this blog post, I show six of the trickiest errors, explain what might be causing the error, and give advice for how to circumvent it.

#1.  ACROSS variable not defined

proc report data=sashelp.class;
column sex, height;
run;

ERROR: There is more than one ANALYSIS usage associated with the column defined by the following elements.

A comma in the COLUMN statement indicates that you want a variable to be used as an ACROSS variable, i.e. one variable stacked on top of another.  This error will occur if your program doesn’t include a DEFINE statement with a usage of ACROSS.

Circumvention: Add a DEFINE statement for the ACROSS variable.

proc report data=sashelp.class;
column sex, height;
define sex /across;
run;

#2.  DISPLAY or GROUP variable needs its own column

proc report data=sashelp.class;
 column sex, height;
 define sex /across;
 define height /group;
run;

ERROR: A DISPLAY or GROUP variable above or below an ACROSS variable requires that there be an ORDER, GROUP, or DISPLAY variable in the report that is not above or below an ACROSS variable.

Often a report requires an ACROSS variable with a character and an analysis variable underneath it. PROC REPORT can create this report, but it has to have a DISPLAY or GROUP variable that is its own column.

Circumvention: Add a grouping variable and place it before the ACROSS variable on the COLUMN statement. The new variable can be defined as NOPRINT so that it will not be seen in the report.

data class;
 set sashelp.class;
 dummy=1;
proc report data=class;
 column dummy sex, height ;
 define dummy /group noprint;
 define sex /across;
 define height /group;
run;

#3.  Variable below ACROSS variable defined as DISPLAY

proc report data=sashelp.class;
 column age sex, height;
 define age /group;
 define sex /across;
 define height /display;
run;

ERROR: There is no statistic associated with XXXX.

This error message is generated when the only variable below an ACROSS variable is defined as DISPLAY.

Circumvention:  Change the DISPLAY variable to be GROUP or add the N statistic after the ACROSS grouping on the COLUMN statement.

proc report data=sashelp.class;
 column age sex, height;
 define age /group;
 define sex /across;
 define height /group;
run;

#4.  Multiple summary rows on the same variable or location

proc report data=sashelp.class;
 column sex sex=sex2 weight;
 define sex /group;
 define sex2 /group;
 break after sex /summarize;
 break after sex2 /summarize;
run;

ERROR: The BREAK variable XXXX is not one of the GROUP or ORDER variables.

PROC REPORT does not have the ability to have multiple summary rows on the same variable or location. You’ll receive this error message if you have used one variable twice on the COLUMN statement (once using an alias), defined it as GROUP or ORDER, and there is a BREAK statement for both the variable and its alias.

Circumvention: Create a new variable in a DATA step that is a copy of the variable and use the new variable on the COLUMN statement instead of an alias.

data class;
 set sashelp.class;
 sex2=sex;
proc report data=class;
 column sex sex2 weight;
 define sex /group;
 define sex2 /group;
 break after sex /summarize;
 break after sex2 /summarize;
run;

#5.  Two different usages for the same variable

proc report data=sashelp.class;
 column age sex name age=age2;
 define age /group;
 define sex /group;
 define age2 /display;
run;

ERROR: XXXX conflicts with earlier use of XXXX.

In some circumstances PROC REPORT will not let you have two different usages for the same variable. In the example above, the variable age cannot be both GROUP and DISPLAY. An alias is most useful when you have an analysis variable that you want multiple statistics for, such as mean, min, or max. However, you can use an alias on any type of variable, but you do have to be careful about the usage issue.

Circumvention: Create a new variable in a DATA step that is a copy of the variable. This way the new variable contains the same information but can be used in any way you choose in the PROC REPORT step.

data class;
 set sashelp.class;
 age2=age;
proc report data=class;
 column age sex name age2;
 define age /group;
 define sex /group;
 define age2 /display;
run;

#6.  No format specified for LINE statement variable

proc report data=sashelp.class;
 column sex name age;
 define sex /group noprint;
 compute before sex;
   line 'this is for gender group ' sex;
 endcomp;
run;

ERROR: XXXX must use a character format.

This error normally occurs when a character variable is used on a LINE statement, and no format is specified after it. On a LINE statement you must specify a format for each item (variable).

Circumvention: Add an appropriate format after the variable on the LINE statement.

proc report data=sashelp.class;
 column sex name age;
 define sex /group noprint;
 compute before sex;
   line 'this is for gender group ' sex $1.;
 endcomp;
run;

See the REPORT procedure documentation for details on each of these statements.
tags: Problem Solvers, PROC REPORT, SAS Programmers