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

Using SUDAAN's proc descript I outputted a dataset that contains p-values. I would like to create a report that shows the p-values rounded to 3 decimals places by sex (in the dataset it's 4 decimal places). The report should look like this:

 Variable
 12
 sexsexsexsex
 MaleFemaleMaleFemale
CONTRASTpvalpvalpvalpval
Latino vs. non-Latino<0.0010.0020.0060.001
US born vs FB0.5890.0560.005<0.001

 

However, I'm running into a couple of issues:

1) When I try to use a format statement to round, if, for example, a p-value is 0.0009 it's incorrectly printed as "<0.001" instead of "0.001."

 

proc format;
value pv 
0-<0.001='<0.001'
other=[5.3];
run;
proc report data=tt nowindows ;
column (contrast) variable, sex, (p_pct) ;
define contrast / group format=test. order=internal ;
define variable / across nozero order=internal ;
define sex / 'sex' across nozero order=internal ;
define p_pct / 'pval' format=pv. ;
run;

2) As a workaround I tried using a compute block, However I can't get my subcolumns. When I use this code

proc report data=tt  nowindows ;
	column (contrast) variable, sex, (p_pct pval) ;
	define contrast / group format=test. order=internal ;
	define variable / across nozero order=internal ;
	define sex / 'sex' across nozero  order=internal ;
	define p_pct /  noprint ;
	define pval / computed format=pv.;
	compute pval;
		pval=round(p_pct,0.001);
	endcomp;
	where contrast in (1:6,17);
run;

I get an error message: ERROR: Variable p_pct is uninitialized

 

This code works but sex is no longer a column header and I don't want to display p_pct, only pval.

proc report data=tt  nowindows ;
	column (contrast) variable, sex p_pct pval  ;
	define contrast / group format=test. order=internal ;
	define variable / across nozero order=internal ;
	define sex / 'sex'  nozero  order=internal ;
	define p_pct / 'p_pct' display ;
	define pval / computed format=pv.;
	compute pval;
		pval=round(p_pct,0.001);
	endcomp;
	where contrast in (1:6,17);
run;

Any assistance would be helpful. Thanks!

 

P.S. Using SAS 9.4

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Since your format said 0-<0.001 = '<0.001' and the value you mention is 0.0009 it is doing what you told it.

 

You would have to manually round before applying the format. Note that SAS supplies a PVALUE format you can use.

 

data example;
   x= 0.0009;
   put x= pvalue6.3;
   x= round(x,0.001);
   put x= pvalue6.3;
run;

View solution in original post

2 REPLIES 2
ballardw
Super User

Since your format said 0-<0.001 = '<0.001' and the value you mention is 0.0009 it is doing what you told it.

 

You would have to manually round before applying the format. Note that SAS supplies a PVALUE format you can use.

 

data example;
   x= 0.0009;
   put x= pvalue6.3;
   x= round(x,0.001);
   put x= pvalue6.3;
run;
nd
Obsidian | Level 7 nd
Obsidian | Level 7

Thanks. I was afraid that I would need a dataset; was hoping that using a compute block could be a workaround. Smiley Sad

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 961 views
  • 0 likes
  • 2 in conversation