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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 823 views
  • 1 like
  • 4 in conversation