Hi all,
I have 2 columns such as below.
col1 col2
xxxxx 0.5
yyyyy 1
zzzz 1
kkkk 1
llllllll 1
xxxxx 1.5
yyyyy 2
zzzz 2
kkkk 2
llllllll 2
................. similarly i have values up to 60.
My COL2 is numeric, Looking for a procedure to find out to TAG the rows containing decimal values, the order can not be changed? (with out converting the column in to character and then using any function to pick the decmial)
I'm not sure I follow. Are you looking to tag/flag non-integers?
@sahoositaram555 wrote:
Hi all,
I have 2 columns such as below.
col1 col2
xxxxx 0.5
yyyyy 1
zzzz 1
kkkk 1
llllllll 1
xxxxx 1.5
yyyyy 2
zzzz 2
kkkk 2
llllllll 2
................. similarly i have values up to 60.
My COL2 is numeric, Looking for a procedure to find out to TAG the rows containing decimal values, the order can not be changed? (with out converting the column in to character and then using any function to pick the decmial)
Basic approach is to see if the value when converted to an integer is equal to the original value. If so then there is no decimal, if there is a difference then there is a decimal portion to the value.
data want; set have; tag = (intz(col2) ne col2); run;
SAS returns 1 for true and 0 for false. So the comparison above would be 1 when the decimal portion returned by the INTZ function is not equal to the original value.
the logic before programming in code seems to be
if decimal present in col2 then ......
in base SAS code try finding something simpler that
if mod( col2, 1 ) then do;
* ~something ~ ;
end;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.