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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.