04-26-2017 06:19 AM
I have one column in that character as well as numeric values are there i need to seperate out those value on base of character and numeric. there is no specific value that we need to seperate out like
Like that i have one column want to seperate the character and numeric.
Thanks & Regards,
04-26-2017 06:33 AM
if notdigit(strip(acnb)) > 0 then acnb_char = acnb; else acnb_num = input(acnb,best.);
notdigit() scans for characters outside 0-9, strip() removes any blanks before notdigit() scans.
04-26-2017 08:25 AM
Thanks for idea.
but the column ACNB is the character column and number and character are there.
so in strip if my value is 0001 then in final table its coming as 1.
that is the problem.
Please suggest if any
04-26-2017 08:45 AM
That output is correct, if you take the string 0001 and set this as a numeric value, then number is 1. there is no such thing as a numeric with preceding zeros. You can apply a format - zX. where X is the number of elements - but what this is doing is displaying the underlying number 1 as 0001, doesen't change the value, and you would need to apply that format to the whole column.
04-26-2017 06:39 AM
Would it not be safer t keep both, for instance in CDISC models you have a character result - which has everything in as its recorded - and also a numeric result where possible. That way you have best of both worlds, a variable to report as it was, and a numeric to do calculations on? As for how to do that:
04-26-2017 07:09 AM
The rules for "character" or "numeric" are more complex since a legitimate number can contain a decimal point or a negative sign, but cannot contain embedded blanks. (We'll leave commas out of the mix here.) A robust way would be:
if acnb > ' ' and input(acnb, ??16.) = . then acnb_character=acnb;
else acnb_numeric = input(acnb, 16.);
You are allowed to use a shorter informat, one that matches the length of your variable.