BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
A_Kh
Barite | Level 11

Hi Community, 

When computing on char type P-value using INPUT function in PROC REPORT compute block I'm getting in the log a NOTE: Invalid argument to function INPUT at line.... (See the code below)..
Looking at the output I don't think there is any issue with computation (as all values less than 0.05 get bolded based on computation).  Although (??) modifier cleared the note from the log  (input(grp1, ?? best.)), I wanted to check in with you to see whether this is the right way to avoid the log note above, or there is more appropriate way to handle it.  

 

Thank you!

data have;
	infile cards dlm=',' truncover;
	length name grp1 grp2 grp3 $ 40;
	input name grp1-grp3 order;
	cards;
Responder	n/N(%), 4/150 (2.67%), 8/154 (5.19%), 10/150 (6.67%), 1
Odds Ratio  (95% CI), 0.798 (0.385-1.657), 2.385 (0.891-6.387), 2.031 (1.080-3.819), 2
P-value, 0.0544, <.0001, 0.0033, 3
;
proc print;run;

title 'Test';
proc report data= have; 
	column order name grp:;
	define order/ noprint;
	define name/ '' width=30;
	define grp1/ 'Group 1' width=15;
	define grp2/ 'Group 2' width=15;
	define grp3/ 'Group 3' width=15;
	compute Name;
		if lowcase(strip(name)) eq 'p-value' then call define(_row_, "style", "style=[font_style=italic]");
	endcomp;
	compute grp1;
		if lowcase(strip(name)) eq 'p-value' and input(grp1, best.) lt 0.05 then call define(_col_, "style", "style=[font_weight=bold]");
	endcomp;
	compute grp2;
		if lowcase(strip(name)) eq 'p-value' and input(grp2, best.) lt 0.05 then call define(_col_, "style", "style=[font_weight=bold]");
	endcomp;
	compute grp3;
		if lowcase(strip(name)) eq 'p-value' and input(grp3, best.) lt 0.05 then call define(_col_, "style", "style=[font_weight=bold]");
	endcomp;
	compute after / style=[bordertopcolor=black bordertopwidth=1pt ];
		line ' ';
	endcomp;
run;
title; 

log:
Capture.PNG


1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

It's a bit of hack, but probably okay for this example.  It will suppress the warning message, and input('<.001',?? best.)  will return a missing value.  Since in SAS a missing value will evalute to less than .05, it will return true.

 

Personally, I'd probably use a different hack.  I'd remove the '<' from the string.  It's still a hack, but at least it's explicit.  I don't like to use ?? in production code, because it suggests there is a lot of messy data you want to ignore.

 

data a ;
  x=input('<.0001',?? best.) ;
  put x= ;

  x=input(compress('<.0001','<'), best.) ;
  put x= ;
run ;
The Boston Area SAS Users Group is hosting free webinars!
Next up: Rick Wicklin presents Ten Tips for Effective Statistical Graphics (with SAS code) on Wednesday March 26.
Register now at https://www.basug.org/events.

View solution in original post

4 REPLIES 4
Quentin
Super User

It's a bit of hack, but probably okay for this example.  It will suppress the warning message, and input('<.001',?? best.)  will return a missing value.  Since in SAS a missing value will evalute to less than .05, it will return true.

 

Personally, I'd probably use a different hack.  I'd remove the '<' from the string.  It's still a hack, but at least it's explicit.  I don't like to use ?? in production code, because it suggests there is a lot of messy data you want to ignore.

 

data a ;
  x=input('<.0001',?? best.) ;
  put x= ;

  x=input(compress('<.0001','<'), best.) ;
  put x= ;
run ;
The Boston Area SAS Users Group is hosting free webinars!
Next up: Rick Wicklin presents Ten Tips for Effective Statistical Graphics (with SAS code) on Wednesday March 26.
Register now at https://www.basug.org/events.
ballardw
Super User

Custom informat will solve that pretty cleanly:

 

proc format;
invalue mypval
'<.0001'=0.0001
other = [8.]
;
run;
title 'Test';
proc report data= have; 
	column order name grp:;
	define order/ noprint;
	define name/ '' width=30;
	define grp1/ 'Group 1' width=15;
	define grp2/ 'Group 2' width=15;
	define grp3/ 'Group 3' width=15;
	compute Name;
		if lowcase(strip(name)) eq 'p-value' then call define(_row_, "style", "style=[font_style=italic]");
	endcomp;
	compute grp1;
		if lowcase(strip(name)) eq 'p-value' and input(grp1, mypval.) lt 0.05 then call define(_col_, "style", "style=[font_weight=bold]");
	endcomp;
	compute grp2;
		if lowcase(strip(name)) eq 'p-value' and input(grp2, mypval.) lt 0.05 then call define(_col_, "style", "style=[font_weight=bold]");
	endcomp;
	compute grp3;
		if lowcase(strip(name)) eq 'p-value' and input(grp3, mypval.) lt 0.05 then call define(_col_, "style", "style=[font_weight=bold]");
	endcomp;
	compute after / style=[bordertopcolor=black bordertopwidth=1pt ];
		line ' ';
	endcomp;
run;
title; 

The only real trick here could 1) deciding what numeric value to have the result from reading <0.0001 should be and 2) making sure that the informat , the Proc Format code, is available when needed.

 

Astounding
PROC Star

Some procedures print p-values using a format.  So the "<.001" is not necessarily the actual value, just the formatted value.  If that is happening here (and it seems like it might be the case because of the bolding and the lack of an error message), just get rid of the INPUT function and refer to the variable name instead.  It's likely already a small numeric value.

A_Kh
Barite | Level 11

Thank you, dear experts, for sharing your knowledge and tips with me!

It is good to know about formatted values generated by stats procedures...
All 3 solutions give me the the desired result. And I just pick the first responder's answer as the solution while all answers have the same level of priority for me. 

 

sas-innovate-white.png

🚨 Early Bird Rate Extended!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Lock in the best rate now before the price increases on April 1.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1265 views
  • 4 likes
  • 4 in conversation