- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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)
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
decimal = floor(col2) - col2;
if decimal = 0 then .....now what??
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I'm not sure I follow. Are you looking to tag/flag non-integers?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
TAG = ^^mod( col2, 1 ) ;
where TAG should be 1 when there are decimals, and 0 when col2 is integer or missing