BookmarkSubscribeRSS Feed
Thylacine
Fluorite | Level 6

I'm importing a csv file with a number which is sometimes without decimals and sometimes with them like( 20 or 5,43) how can i store them in one variable with right values. If i use comma. the number without decimals gets wrong value and so on. 

5 REPLIES 5
Reeza
Super User

Use the BEST informat, note that this is the default SAS behaviour as well.

 

data check;
informat myNum best12.;
format myNum best12.;
input myNum;
cards; 2 4 4.32 2.3 1.0 3 ; run; proc print;run;
art297
Opal | Level 21

If your example is indicative of what your data really look like, sounds like you should be using the commax informat rather than the comma format. That will let you read numbers like 5,43 as 5.43

 

Art, CEO, AnalystFinder.com

 

Thylacine
Fluorite | Level 6

I'm importing a csv file with a number which is sometimes without decimals and sometimes with them like( 20 or 5,43) how can i store them in one variable with right values. If i use comma. the number without decimals gets wrong value and so on. 

PaigeMiller
Diamond | Level 26

You have a CSV file and sometimes the decimal is also a comma?

 

Can you show us a portion of the CSV file that illustrates the problem so we can get some idea of what the data looks like?

--
Paige Miller
Reeza
Super User

Please note that I've merged these two threads as the topic is identical.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 848 views
  • 1 like
  • 4 in conversation