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.
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;
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
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.
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?
Please note that I've merged these two threads as the topic is identical.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.