behaviour of report procedure while reporting numeric variables

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

behaviour of report procedure while reporting numeric variables

My objective is to print the numeric values as it is with report procedure.

Here is a problem when i tried to print numeric data with report procedure. this is the sample code.

data numb;

input num;

cards;

25

16

87

45

29

36

;

proc report nowd;

run;

the log is displayed as:

758  proc report nowd;

759  run;

NOTE: There were 6 observations read from the data set WORK.NUMB.

NOTE: PROCEDURE REPORT used (Total process time):

      real time           0.03 seconds

      cpu time            0.03 seconds

The problem is that in output window, It has reported sum of all the records, and not the values.

Then I have used order option in the define statement. the code is like this:

proc report nowd;

column num;

define num/order;

run;

Then It has reported the 6 records in sorted order.

Even if we use option order=data, it will produce the sum with numeric variable. When character variable is printed, it will print all values as it is(no need of order option).


Accepted Solutions
Solution
‎09-04-2014 05:53 AM
Super User
Super User
Posts: 7,720

Re: behaviour of report procedure while reporting numeric variables

Hi,

What you are seeing is that as you have not supplied much in the way of options on the proc report then it is using defaults behind the scene, that default being group so the result is the sum of the numbers.  You need to tell proc report that you want that column as a display variable:

proc report data =numb nowd missing style=statistical;

  columns num;

  define num / "Number" display;

run;

I would suggest to avoid the "shortcuts" - missing run; statements, assuming proc should use last dataset etc.  Makes reading it harder.

View solution in original post


All Replies
Solution
‎09-04-2014 05:53 AM
Super User
Super User
Posts: 7,720

Re: behaviour of report procedure while reporting numeric variables

Hi,

What you are seeing is that as you have not supplied much in the way of options on the proc report then it is using defaults behind the scene, that default being group so the result is the sum of the numbers.  You need to tell proc report that you want that column as a display variable:

proc report data =numb nowd missing style=statistical;

  columns num;

  define num / "Number" display;

run;

I would suggest to avoid the "shortcuts" - missing run; statements, assuming proc should use last dataset etc.  Makes reading it harder.

Occasional Contributor
Posts: 6

Re: behaviour of report procedure while reporting numeric variables

Hi ,

Thank you that is great!!!

Your suggestion is also helpful and a must follow for good programming.

Thanks a ton!!!

Super User
Super User
Posts: 7,720

Re: behaviour of report procedure while reporting numeric variables

No probs.  Just to add, if you are interested in seeing the defaults (and I was actually wrong, its not group but sum) then you can add the word list to the proc report and see what it is actually generating - very useful not only for seeing the code, but copying and pasting to save you typing!

proc report nowd list;

run;

Generates:

PROC REPORT DATA=WORK.NUMB LS=256 PS=55  SPLIT="/" NOCENTER ;
COLUMN  num;

DEFINE  num / SUM FORMAT= BEST9. WIDTH=9     SPACING=2   RIGHT "num" ;
RUN;

Occasional Contributor
Posts: 6

Re: behaviour of report procedure while reporting numeric variables

Fantastic!!!

🔒 This topic is solved and locked.

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

Discussion stats
  • 4 replies
  • 218 views
  • 1 like
  • 2 in conversation