BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Quodly
Obsidian | Level 7

hello,

 

i use the odbc engine to retrieve data from a snowflake table. it contains a variable x of integers which seem to lose precision in sas. for example:

 

Quodly_1-1634219978108.png

 

y = put(x, best32. -l);

 

i think that this is related to this question:

 

https://stackoverflow.com/questions/10933725/long-digit-reading-in-sas 

 

as i do not use proc import, this does not help me much, though.

 

is it possible to convert a numeric snowflake variable into a sas character variable without losing precision?

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

Snowflake SQL contains functions to do column type conversions: https://docs.snowflake.com/en/sql-reference/functions-conversion.html

 

Just add the required conversion from numeric to character (VARCHAR) in a SAS passthru SQL query and then SAS will read the character version without any precision loss.

View solution in original post

2 REPLIES 2
ballardw
Super User

SAS precision for large numbers means that you will need to do the conversion before bringing it into SAS. Possibly export the data from the other data source and then read the data with a data step as character.

 

 

SASKiwi
PROC Star

Snowflake SQL contains functions to do column type conversions: https://docs.snowflake.com/en/sql-reference/functions-conversion.html

 

Just add the required conversion from numeric to character (VARCHAR) in a SAS passthru SQL query and then SAS will read the character version without any precision loss.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1198 views
  • 2 likes
  • 3 in conversation