- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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:
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 ;
Next up: SAS Trivia Quiz hosted by SAS on Wednesday May 21.
Register now at https://www.basug.org/events.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 ;
Next up: SAS Trivia Quiz hosted by SAS on Wednesday May 21.
Register now at https://www.basug.org/events.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.