I have the following code
t1.Count =input(t1.Count, 4.)
trying to convert char to number but I am getting following error any idea
ERROR: Expression using equals (=) has components that are of different data types.
It looks like you are doing this with SQL so are you attempting to use the numeric value in a comparison or create a new variable?
Comparison
where input(t1.count,4.) = 245
or
where input(t1.count,4.) = b.numericvariable
new variable
Select input(t1.count,4.) as Count
As written you are comparing the current character value to the converted numeric and that is what generates an error.
More information about what you attempting to do may be needed.
This is what I am trying to do T1.Count1 is a char value and I am trying to convert to Num.
I thought if I assign the new name count can work as show below:
CREATE TABLE AUTO.QUERY_FOR_BUS_DAY AS
SELECT t1.'Active_Messages'n,
t1.'Total_Active_Messages'n,
t1.Aging,
Count =input(t1.Count1, 4.),
t1.'Age_Date'n,
t1.'Report_Date'n,
I think the syntax for this would be:
input(t1.Count1, 4.) as Count,
@Davar wrote:
This is what I am trying to do T1.Count1 is a char value and I am trying to convert to Num.
I thought if I assign the new name count can work as show below:
CREATE TABLE AUTO.QUERY_FOR_BUS_DAY AS
SELECT t1.'Active_Messages'n,
t1.'Total_Active_Messages'n,
t1.Aging,
Count =input(t1.Count1, 4.),
t1.'Age_Date'n,
t1.'Report_Date'n,
Using a = like that in a select creates a boolean (true/false 1/0 valued) un-named variable that SAS will assign a name for.
Please see this example:
data have; input x; datalines; 1 2 ; run; proc sql; create table result as select x, x=1 from have; quit;
When I ran that on my install I get a variable name _TEMA001, YMMV.
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.