Hello,
Every one
Have :
var1
+2
3+
-1
4-
34.56
Zero
NA
want
var1 var2
+2 +2
3+ 3+
-1 -1
4- 4-
34.56 .
Zero Zero
NA NA
I am converting character to numeric, I am using
input(strip(var1), ?? best.);
but problem is when use this syntx I am not able to get var2 correct for +3,+2, or such values but I am getting correct values for 3+,2+ ,zero, NA
my data has +3 and I need it +3 in to var2.
Thanks in advance
Less convoluted
data have;
input var1 $;
cards;
+2
3+
-1
4-
34.56
Zero
NA
;
data want;
set have;
if notdigit(compress(strip(var1),'.')) then var2=var1;
run;
Is the requirement that var2 has to be numeric? You don't specifically state that. Leaving var2 as character makes everything simple.
If so, then you would need to create a specific picture format for your situation.
Thanks for responding on the question. Yes I think I forget to mention about that.
Var1 is in Character
Var2 is also in Character I just dont want to see any Numeric values in to this such as 9,4.5, 8.937, so on
Thanks again.
data have;
input var1 $;
cards;
+2
3+
-1
4-
34.56
Zero
NA
;
data want;
set have;
var2=ifc(notdigit(compress(strip(var1),'.')),var1,' ');
run;
Less convoluted
data have;
input var1 $;
cards;
+2
3+
-1
4-
34.56
Zero
NA
;
data want;
set have;
if notdigit(compress(strip(var1),'.')) then var2=var1;
run;
@novinosrin Thanks for posting solution on that. I really appreciated for simple version however I figured for IFC but may be it helps for novice. Thanks again keep helping 🙂 🙂
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.