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

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];

1 ACCEPTED SOLUTION

Accepted Solutions
snoopy369
Barite | Level 11

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

13 REPLIES 13
snoopy369
Barite | Level 11

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.

robertrao
Quartz | Level 8

Hi,

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

Regards

robertrao
Quartz | Level 8

Hi,

Thanks for the Help.

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

Thanks

Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

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"?

Cynthia_sas
SAS Super FREQ

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

robertrao
Quartz | Level 8

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

Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

thanks Cynthia,

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

Base SAS(R) 9.2 Procedures Guide

robertrao
Quartz | Level 8

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

Tal
Pyrite | Level 9 Tal
Pyrite | Level 9

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

Cynthia_sas
SAS Super FREQ

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
Reeza
Super User

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"?

snoopy369
Barite | Level 11

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.

robertrao
Quartz | Level 8

Sorry that was a typo for the ERROR..

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