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