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];
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.
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.
Hi,
If I correct the use analysis on those stats then there is also no need of aliasing them in the first case
Regards
Hi,
Thanks for the Help.
After I do the across how can i get the acrossed variables in the order i WANTED???
Thanks
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"?
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
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
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
As far as i know order can take the following values only: data,freq,formatted, and internal
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;
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"?
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.
Sorry that was a typo for the ERROR..
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.