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.
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.
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.