Help using Base SAS procedures

Proc Report Question

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,041
Accepted Solution

Proc Report Question

Please find the code below

I want different formats as stated in the define statement

For N i wanted 10.0 format

For Mean and STD i want 10.2 format

I get an weeor : N mean and STD do not exist after running the proc report!!!!!

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

proc report data=test nowd ;


column lab,VALUE,(n=dur_n mean=dur_mean std=dur_std);

define  dur_n/analysis 'N' ''f=comma10.0 style=[fontsize=.9];

define  dur_mean/analysis 'MEAN' ''f=comma10.2 style=[fontsize=.9];

define  dur_std/analysis 'STD' ''f=comma10.2 style=[fontsize=.9];


Accepted Solutions
Solution
‎12-05-2013 12:46 PM
Super Contributor
Posts: 253

Re: Proc Report Question

Posted in reply to robertrao

You aren't being thorough in your defines, and you're using ANALYSIS wrong.

data test;

input id lab $ value;

cards;

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

;;;;

run;

proc report data=test nowd ;

column lab,VALUE,(n=dur_n mean=dur_mean std=dur_std);

define lab/across;

define value/analysis;

define  dur_n/ 'N' f=comma10.0 style=[fontsize=.9];

define  dur_mean/'MEAN' f=comma10.2 style=[fontsize=.9];

define  dur_std/'STD' f=comma10.2 style=[fontsize=.9];

run;

The n/mean/std columns are display, not analysis( you're not further analyzing them). Value is what is analysis.

View solution in original post


All Replies
Solution
‎12-05-2013 12:46 PM
Super Contributor
Posts: 253

Re: Proc Report Question

Posted in reply to robertrao

You aren't being thorough in your defines, and you're using ANALYSIS wrong.

data test;

input id lab $ value;

cards;

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

;;;;

run;

proc report data=test nowd ;

column lab,VALUE,(n=dur_n mean=dur_mean std=dur_std);

define lab/across;

define value/analysis;

define  dur_n/ 'N' f=comma10.0 style=[fontsize=.9];

define  dur_mean/'MEAN' f=comma10.2 style=[fontsize=.9];

define  dur_std/'STD' f=comma10.2 style=[fontsize=.9];

run;

The n/mean/std columns are display, not analysis( you're not further analyzing them). Value is what is analysis.

Super Contributor
Posts: 1,041

Re: Proc Report Question

Posted in reply to snoopy369

Hi,

If I correct the use analysis on those stats  then there is also no need of aliasing them in the first case

Regards

Super Contributor
Posts: 1,041

Re: Proc Report Question

Posted in reply to snoopy369

Hi,

Thanks for the Help.

After I do the across how can i get the acrossed variables in the order i WANTED???

Thanks

Super Contributor
Super Contributor
Posts: 444

Re: Proc Report Question

Posted in reply to robertrao

you can use define lab/across  order=data descending  or define lab/across  order=data depending on which value of "lab" you want first

i have a  question to the experts on your code though:

does really "style" make any difference here or is it effective only if we export the results via "ODS"?

SAS Super FREQ
Posts: 8,868

Re: Proc Report Question

Hi:

  Since the OP didn't mention the version of SAS or show ODS statements, it's hard to figure. Using STYLE only works with ODS, so I would think that either the default ODS HTML destination is on (for 9.3 or 9.4) or the OP ran the code in EG (with SASReport destination ON) or the OP just left off the ODS code.

  Personally, I prefer to be explicit with my STYLE= overrides and PROC REPORT, meaning style(column) and/or style(header)  in the DEFINE statement. Yes, it is more typing, but down the line when you *DO* need to specify different attributes for the different locations or report areas, it will be a trivial change. And, for font sizes, I prefer to be explicit about the unit of measure for the font....like using PT, for example.

cynthia

Super Contributor
Posts: 1,041

Re: Proc Report Question

Hi,

Thanks for the reply.

firstly lab is a character variable

I understand that if I use order=data what ever is the order in the dataset we get it in that order in the report

when I use descending .........since lab is a character variable how would it order it?????I know that I can use descending on numeric variable

Could you explain??????

define lab/across  order=data descending  or define lab/across  order=data

Super Contributor
Super Contributor
Posts: 444

Re: Proc Report Question

Posted in reply to robertrao

thanks Cynthia,

@Robert,yes  you can sort char  in asc or desc order

Base SAS(R) 9.2 Procedures Guide

Super Contributor
Posts: 1,041

Re: Proc Report Question

Thanks Tal.

cnt it be written like

define lab/across order= descending instead of

define lab/across order= data descending

define lab/across  order=data descending  or define lab/across  order=data

Super Contributor
Super Contributor
Posts: 444

Re: Proc Report Question

Posted in reply to robertrao

As far as i know order can take the following values only: data,freq,formatted, and  internal

SAS Super FREQ
Posts: 8,868

Re: Proc Report Question

Posted in reply to robertrao

Hi:

  You can use ORDER=DATA with or without DESCENDING and you can use DESCENDING with or without ORDER=DATA. See the attached program for an example of each.

Cynthia

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

  proc report data=sashelp.class nowd

    style(summary)=Header;

    title '1a) Ascending Report is Default for AGE';

    column sex ( age,(height weight));

    define sex / group

           style(column)=Header;

    define age / across 'Gender Avg';

    define height / mean f=7.2;

    define weight / mean f=7.2;

    rbreak after / summarize;

  run;

 

  proc report data=sashelp.class nowd

    style(summary)=Header;

    title '1b) Descending Report';

    column sex ( age,(height weight));

    define sex / group

           style(column)=Header;

    define age / across 'Gender Avg' descending;

    define height / mean f=7.2;

    define weight / mean f=7.2;

    rbreak after / summarize;

  run;

   

  ** sort by name will force different order for AGE;

  proc sort data=sashelp.class out=class;

    by name;

  run;

       

  proc print data=class;

  title '2a) what order is AGE after sort-- note that 14 is first, then 13, then 12, then 15';

  run;

     

  proc report data=class nowd

    style(summary)=Header;

    title '2b) ORDER=DATA  Report';

    title2 'Columns are in the order that AGE appears in sorted data';

    column sex ( age,(height weight));

    define sex / group

           style(column)=Header;

    define age / across 'Gender Avg' order=data;

    define height / mean f=7.2;

    define weight / mean f=7.2;

    rbreak after / summarize;

  run;

     

  proc report data=class nowd

    style(summary)=Header;

    title '3) ORDER=DATA with Descending Report';

    title2 'Columns are in descending order of the data order';

    column sex ( age,(height weight));

    define sex / group

           style(column)=Header;

    define age / across 'Gender Avg' order=data descending;

    define height / mean f=7.2;

    define weight / mean f=7.2;

    rbreak after / summarize;

  run;

ods _all_ close;

title; footnote;


simple_usage_descending.pngorder_data_descending.png
Super User
Posts: 19,822

Re: Proc Report Question

Posted in reply to robertrao

What does your log say when you submit that code?

It looks like you have extra quotation marks besides each f, are those intentional?

What is a "WEEOR"?

Super Contributor
Posts: 253

Re: Proc Report Question

WEEOR is what you get when you type ERROR one-handed and your hand is shifted over one for the first part of ERR.

Or, it's the sound my son's toys make when he's sitting on them and causing their motors to die.

Super Contributor
Posts: 1,041

Re: Proc Report Question

Sorry that was a typo for the ERROR..

🔒 This topic is solved and locked.

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

Discussion stats
  • 13 replies
  • 440 views
  • 4 likes
  • 5 in conversation