- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
I have a column variable named Pvalue, then I use call symput to output a value. for example:
I have a simple dataset below:
variable Pvalue Pvalue_1
score 0.00003 <0.001
math 0.02 0.02
The format of Pvalue_1 is Pvalue5.3 get from Pvalue.
I am using below code to output a variable's value:
data _null_;
set scatter1;
if variable="score";
call symput("P", Pvalue_1);
run;
%put (&P);
But the output P is 0.00003 not <0.001
Any idea to solve this? I want p is <0.001.
Thanks,
C
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you do not specify a Format for your numeric variable then the result is converted using BEST fromat
Macro variables only handle text so you need to tell SAS exactly which text you want.
Try
call symput("P", Put( Pvalue_1, pvalue6.3));
That will have a trailing 0 for 0.020 but should not be a problem for most uses.
You may want to consider using Call SYMPUTX to reduce the chances of unwanted leading spaces in some uses.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
A very small correction to your code solves this:
data scatter1;
input variable $ Pvalue Pvalue_1 $;
datalines;
score 0.00003 <0.001
math 0.02 0.02
;
data _null_;
set scatter1;
if variable="score" then call symput("P", Pvalue_1);
run;
%put (&P);
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you do not specify a Format for your numeric variable then the result is converted using BEST fromat
Macro variables only handle text so you need to tell SAS exactly which text you want.
Try
call symput("P", Put( Pvalue_1, pvalue6.3));
That will have a trailing 0 for 0.020 but should not be a problem for most uses.
You may want to consider using Call SYMPUTX to reduce the chances of unwanted leading spaces in some uses.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes, that works!!
Thanks so much!!!!