Help using Base SAS procedures

Customising p-value formats in output of procs

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 17
Accepted Solution

Customising p-value formats in output of procs

Last week I found a post here on how to change the format of the p-values output by proc corr (via its template). I wonder whether it is possible to change the formats of ALL the p-values output by ALL SAS procedures, so that they are all the same, something like best9. for example?

(SASUniversityEdition, version 9.4)


Accepted Solutions
Solution
‎03-29-2016 09:05 AM
Super User
Posts: 9,676

Re: Customising p-value formats in output of procs

Opps. You need the variable name firstly. For the following example . the variable name are pweight,pheight :



ods select none;
ods output PearsonCorr=corr;
proc corr data=sashelp.class;
var weight height;
run;
ods select all;
proc print data=corr noobs;
format pweight pheight pvalue.;
run;



View solution in original post


All Replies
Super User
Posts: 9,676

Re: Customising p-value formats in output of procs

There is already a format PVALUE. you can use :

data _null_;
p=.00003;
put p= pvalue.;
p=.3;
put p= pvalue.;
run;




If you want output like SPSS : * ** *** 
Make a format for it :

proc format;
value fmt
 low-0.05='***'
 0.05<-0.1='**'
 0.1<-high='*';
run;
data _null_;
p=.00003;
put p= fmt.;
p=.3;
put p= fmt.;
run;

Occasional Contributor
Posts: 17

Re: Customising p-value formats in output of procs

Dear Ksharp,

    Thank you for your reply; I was not aware of the pvalue. format. But how do I modify it from its current definition (any p-value < 1E-4 becomes <.0001) to something else, best9. for instance?

    Can I apply your second example ('like SPSS') to output produced by a procedure like proc corr?

 

Norman

Super User
Posts: 10,497

Re: Customising p-value formats in output of procs

PVALUE is a SAS supplied format and you cannot modify it or create your own format with the same name in an attempt to override it. (I tried to confirm my suspicion).

 

Any procedure that you can create an output data set can have the the results printed or displayed using another report procedure like Proc Report or Proc Tabulate and associate the desired format with the value displayed.

 

 

Occasional Contributor
Posts: 17

Re: Customising p-value formats in output of procs

[ Edited ]

Dear Ballardw,

    Thank you for your reply.

    I followed your suggestion with proc corr and proc report. Proc report does not reproduce the p-values of proc corr in its listing, only MEANS, STD, N, and CORR, no p-values at all; adding a format statement affects the output of the original variables only.

    Have I missed something?

 

Norman

Super User
Posts: 9,676

Re: Customising p-value formats in output of procs

Just apply the PVALUE. or the format I created above to proc corr .

proc corr.........
.........
format pvalue pvalue.;
OR
format pvalue best9.;


Occasional Contributor
Posts: 17

Re: Customising p-value formats in output of procs

Dear Ksharp,

    Thank you for your reply and your continuing willingness to help.

    I tried yor suggestion and received the following:  "WARNING: Variable PVALUE not found in data set WORK.NORMAN.". The inability to modify the built-in format PVALUE has also been reported by ballardw (Super User) in his post above.

Solution
‎03-29-2016 09:05 AM
Super User
Posts: 9,676

Re: Customising p-value formats in output of procs

Opps. You need the variable name firstly. For the following example . the variable name are pweight,pheight :



ods select none;
ods output PearsonCorr=corr;
proc corr data=sashelp.class;
var weight height;
run;
ods select all;
proc print data=corr noobs;
format pweight pheight pvalue.;
run;



Occasional Contributor
Posts: 17

Re: Customising p-value formats in output of procs

Dear Ksharp,

    BINGO! That did it. Thank you. Thank you very much.

 

Norman

☑ This topic is SOLVED.

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

Discussion stats
  • 8 replies
  • 951 views
  • 0 likes
  • 3 in conversation