BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
robertrao
Quartz | Level 8

Hi ,

Could someone point to me where I am going wrong????

ERROR: There is a statistic but no ANALYSIS usage associated

       with the column defined by the following elements.

       Name                              Usage

       --------------------------------  --------

       mean                              STATISTIC

data test;
input Category$ value;
cards;
Biscuits 20
Biscuits 25
Biscuits 19
Biscuits 33
Biscuits 10
Choclate 80
Choclate 30
Choclate 22
Choclate 09
Oranges 12
Oranges 20
Oranges 20
Oranges 25
Oranges 33
Oranges 36
;
run;

ods html file='x.html' style=sasweb;
proc report data=test nowd ;
columns Category value(mean);
   define Category/group;
  define value/analysis;
  break after Category/summarize skip ol style=[font_weight=bold font_style=italic font_size=9pt];

                rbreak after / summarize dul style =[font_weight=bold font_style=italic font_size=9pt];

 
  run;
ods html close;

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

HI,

Then I'm confused. If you understood the concept I explained, why did you post code showing VALUE(MEAN) without showing the comma? That doesn't make sense in terms of REPORT syntax. The new code you posted makes a bit more sense. ACROSS is a usage that allows PROC REPORT to do cross-tabular reports, by making a column (or set of columns) for each UNIQUE value of the ACROSS item. In your example code, the ACROSS item is the LAB variable and so you would have 1 unique column for every value of LAB and then underneath each unique value of LAB, you would have the MEAN and MEDIAN of the VALUE variable. As I explained in my previous post...see the @2 reason for using parentheses that I gave...you use parentheses with a comma when you want to ask for more than 1 statistic or variable to appear underneath an ACROSS item.

In the code shown in my screen shot and code, using SASHELP.CLASS, the #3 report is similar to what you show in your code (except it is a complete working program) and the #4 example is the more common usage of ACROSS, where there is a GROUP variable going down the ROWS and the ACROSS item going across the columns.

cynthia


using_across.png

View solution in original post

9 REPLIES 9
Cynthia_sas
SAS Super FREQ

Hi,

  I suspect that PROC REPORT is as confused as I am. I don't speak in error messages, however. Why do you have value(mean) in your code? That is not usual PROC REPORT syntax (without a comma between them). PROC REPORT thinks you are asking for the MEAN statistic, but does not know which variable should be used to generate the mean. There are 2 ways that you could ask for the mean statistic for the variable named VALUE. Consider the following example (shown in the screen shot) using SASHELP.CLASS, where AGE is the group item and HEIGHT is the ANALYSIS item. Usually parentheses are used for one of two reasons 1) to request a spanning header (which you are not doing) or 2) to request more than 1 variable to get nested underneath an ACROSS item (which you are not doing). So your parentheses aren't doing what I suspect you think they are doing. You must have tried some syntax from another language or procedure thinking that the value(mean) would generate the mean statistic for the VALUE variable. However, you only need to ask for the MEAN statistic on the DEFINE statement for VALUE (Method 1) or you need to "cross" or "nest" the MEAN statistic with the VALUE variable by using the comma operator (Method 2).

cynthia


proc_report_two_methods.png
robertrao
Quartz | Level 8

Hi,

Thanks for the reply. I understood the concept you explained in your prior post.

I alsio wanted to learn what this syntax  means for the below example???

column lab,VALUE,(mean median);

define  lab/across order=data '';

define  VALUE/analysis ];

ID   lab         value
101  heme         33
101  heme         29
101  platelet     5
101  platelet     3
101  platelet     8
101  platelet     9
102  heme         33
102  heme         29
102  heme         25
102  heme         23
102  platelet     8
102  platelet     9

Cynthia_sas
SAS Super FREQ

HI,

Then I'm confused. If you understood the concept I explained, why did you post code showing VALUE(MEAN) without showing the comma? That doesn't make sense in terms of REPORT syntax. The new code you posted makes a bit more sense. ACROSS is a usage that allows PROC REPORT to do cross-tabular reports, by making a column (or set of columns) for each UNIQUE value of the ACROSS item. In your example code, the ACROSS item is the LAB variable and so you would have 1 unique column for every value of LAB and then underneath each unique value of LAB, you would have the MEAN and MEDIAN of the VALUE variable. As I explained in my previous post...see the @2 reason for using parentheses that I gave...you use parentheses with a comma when you want to ask for more than 1 statistic or variable to appear underneath an ACROSS item.

In the code shown in my screen shot and code, using SASHELP.CLASS, the #3 report is similar to what you show in your code (except it is a complete working program) and the #4 example is the more common usage of ACROSS, where there is a GROUP variable going down the ROWS and the ACROSS item going across the columns.

cynthia


using_across.png
robertrao
Quartz | Level 8

Hi

for the below data I am requesting N Mean and MEDIAN

How can I get 10.0 format for N

and 10.2 format for MEAN AND MEDIAN??

column lab,VALUE,(n mean median);

define  lab/across order=data '';

define  VALUE/analysis;

ID   lab         value
101  heme         33
101  heme         29
101  platelet     5
101  platelet     3
101  platelet     8
101  platelet     9
102  heme         33
102  heme         29
102  heme         25
102  heme         23
102  platelet     8
102  platelet     9

snoopy369
Barite | Level 11

Your best bet is to define a column alias.

proc report data=test nowd ;

columns Category value,(mean=vmean median=vmedian);

   define Category/group;

  define value/analysis;

  define vmean/format=10.2;

  define vmedian/format=10.;

  break after Category/summarize skip ol style=[font_weight=bold font_style=italic font_size=9pt];

                rbreak after / summarize dul style =[font_weight=bold font_style=italic font_size=9pt];

 

  run;

robertrao
Quartz | Level 8

Hi,

Thanks for the reply,

Somehow it does not work that way

I get an ERROR :variable N,MEAN, and STD are not on FILE

Thanks

Reeza
Super User

1. New question=New Thread/Post

2. Post your code.

snoopy369
Barite | Level 11

Then you're not paying attention to the detail in my post.

mean=vmean

...

define vmean/ ... ;

You can't use MEAN in the define statement.  You need an alias, hence VMEAN.

And agreed, this should really be a new post.

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
  • 9 replies
  • 6169 views
  • 5 likes
  • 4 in conversation