I have number like 11 in character form now I have to convert it in numeric number, how can I do this
use input statment
like:
num = input('56',6.);
Check: Converting a Character Variable to a Numeric Variable
but i have to do in proc IML and input statement is not working in IML
Use the NUM function. You could also use the INPUTN function if you want to apply a general informat.
Will this work within proc IML ?
Yes, this is the SAS/IML forum. If it doesn't work then you should post your code so that we can see what you are trying to do.
I stored value 11 in ij
and want to convert it in numeric form with width 2 and decimal place 0 and store in ijn
ijn=inputn(ij,6.<,2<,0>>);
ijn=input(ij, 2.0);
No, the INPUT function is not supported in SAS/IML. However, you can use the INPUTN format like this:
ijn = inputn(ij, "Best6.");
I use following command and its work for me
ijn=inputn(ij,'6.',2,0);
Perhaps you are getting confused by the difference between informats and formats. When you use the NUM function, it uses a BEST. format to convert the characters to numbers. This is what you want to do. If you want to display the numbers with a 6.2 format, you can use the FORMAT= option on the PRINT statement, as follows:
proc iml;
x = {"1" "11" "2.135" "8" "-3.14"};
y = num(x);
print y; /* BEST format */
print y[format=6.2];/* 6.2 format */
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.