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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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