SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Different numeric formats

Reply
Occasional Contributor
Posts: 11

Different numeric formats

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. 

Super User
Posts: 17,829

Re: Different numeric formats

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;
PROC Star
Posts: 7,363

Re: Different numeric formats

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

 

Occasional Contributor
Posts: 11

Combining numeric formats

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. 

Trusted Advisor
Posts: 1,615

Re: Combining numeric formats

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?

Super User
Posts: 17,829

Re: Combining numeric formats

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

Ask a Question
Discussion stats
  • 5 replies
  • 196 views
  • 1 like
  • 4 in conversation