R RODBC - sqlSave decimal precision issues - rodbc

I'm using sqlSave from R to Oracle using RODBC. I'm saving numbers with decimal places and getting extra decimal places. For example:
195.45 from R shows up as
192.45000000000002 in Oracle

Related

Spotfire data format from Oracle database

I am pulling data from an Oracle database into Spotfire. For some reason, Spotfire formats all numbers as currency with 2 decimals. In my data sets there are a significant number of columns that should be integers. Having them come in as currency doesn't cause any calculation issues that I've found, but it is a formatting issue when columns that obviously should not have decimals are displaced with them.
I have tried using the CAST AS SMALLINT, INTEGER, and also ROUND in my SQL statements to try and get rid of the decimal places. So far, they have all been unsuccessful.
Any ideas on how I can get Spotfire to import numbers with the desired format, or am I going to have to manually change them after they are imported?
Below is an example of some of the functions I have tried.
> SELECT
>
> NAME,
>
> CAST(X_ID AS SMALLINT) X_ID,
>
> CAST(Y_ID AS INTEGER) Y_ID,
>
> ROUND(Z_ID,0) AS Z_ID,
>
> FROM TABLE
Thanks
Spotfire is importing It to the largest most precise data type needed. If you want to display it differently then simply go to Edit > Column Properties, click on the column in question and change the format. You can also do this for each individual chart if you don’t want to make a global change

How to add zero in decimal number in hive.?

I have some data in my hive table which have different number of tailing digits after decimal, I used decimal(precision,scale) function so that i can get data with two tailing digit after decimal.
for decimal(10,2) function-
input 123.123
output 123.12
but for input 123.1
output was 123.1 and i want it to be 123.10
How can i get data in my desired format.?
Tailing 0 after decimal getting trim for release prior to 0.14 in Hive. This issue is fixed in 0.14 release. Jira Id for reference :-
https://issues.apache.org/jira/browse/HIVE-7373

Loading a fixed width format file into R with different row / variable lengths

I am attempting to load the following data into R - using read.fwf:
sample of data
20100116600000100911600000014000006733839
20100116600000100912100000019600005648935
20100116600000100929100000000210000080787
20100116600000100980400000000090000000000
3010011660000010070031144300661101000
401001166000001000000001001
1010011660000020016041116664001338615001338115150001000000000000000000000000010001000100000000000000000000162002117592200001051
20100116600000200036300000001000005692222
however the first number in the row indicates which variables are coded in that line and they have different lengths so the 'widths' vector for lines starting with 1 is different from the 'widths' vector for lines starting with 2 and so on.
Is there a way I can do this without having to read the data in four times? (Note that each case has differing numbers of rows too)
Thank you, Maria

Creating new format in SAS

I would like to create a format in SAS, that converts float into text, e.g.
1.7 should be converted into 'one point seven'. Float contains three symbols only - a digit, a point and a digit.
I know this could be solved by creating data set containing all variations and then format based on this set, but it doesn't satisfy me at all.

Hive Data Type : Double Precision & Scale

I am using CDH 5.3.0 and Hive 0.12. I am having a Hive table with columns defined as double.
I am loading data to these double columns with 2 scale of precision after decimal point from a HDFS sequence file. For example, in my HDFS sequence file my data is like - 100.23 or 345.00. I need to choose double as my data value can be a big value like "3457894545.00"
My requirement is to display two scale precision after decimal point while querying to the Hive table. So with the example data, mentioned above, if i query for this column then I would need to see the value as "100.23" or "345.00".
But with Hive 0.12, I am getting only single precision after decimal point, i.e. value is getting truncated to "100.2" or "345.0".
I tried with "decimal" data type giving syntax as "decimal(3,2)" but in that case my value is getting completely rounded off i.e. "100" or "345".
I was goggling to see if there is any option to define custom precision to a double data type and found that custom precision can be given from hive 0.13 on wards.
Is Hive 0.12 double data type shows only single precision after decimal point. Do i need to apply any custom fix. Kindly suggests.
Thanks in advance.
You should declare as decimal(5,2).
The syntax is DECIMAL(precision, scale). Precision means the number of digits of this number including the digits after the dot.

Resources