Hi,
I have to import the file.csv, that contains a fields with this values:
VALUE
3456
-4567
456,8
Which is it, the best format for import that values?
Usually I use best12. , but in this case I have some trouble with the comma. I also use COMMAx.w..but it doesn't work.
I'm not able to find correct format.
Some of you has some good suggestion?
BEST is a FORMAT, not an INFORMAT. The normal numeric informat nn., which is also known as the F (I assume for FIXED?) informat works for the types of values that the BEST format produces. If you use BEST12. as your INFORMAT then SAS will silently just use the F12. or 12. informat. Do NOT include a decimal value on the INFORMAT because then SAS will divide any input string that does not have a period in it by that many powers of ten.
If your values might have embedded commas and/or dollar signs then use the COMMA (which is also known as the DOLLAR) informat to read them. That informat will first remove the commas and dollar signs and then use the normal numeric informat.
If your numbers are using commas for decimal places and periods for thousands separators then use the COMMAX informat.
data want ;
infile cards truncover ;
input num commax32. ;
cards;
3456
-4567
456,8
;
Explain what you think is the right way to import the third row which reads
456,8
because we don't know what you think should be done with this row
BEST is a FORMAT, not an INFORMAT. The normal numeric informat nn., which is also known as the F (I assume for FIXED?) informat works for the types of values that the BEST format produces. If you use BEST12. as your INFORMAT then SAS will silently just use the F12. or 12. informat. Do NOT include a decimal value on the INFORMAT because then SAS will divide any input string that does not have a period in it by that many powers of ten.
If your values might have embedded commas and/or dollar signs then use the COMMA (which is also known as the DOLLAR) informat to read them. That informat will first remove the commas and dollar signs and then use the normal numeric informat.
If your numbers are using commas for decimal places and periods for thousands separators then use the COMMAX informat.
data want ;
infile cards truncover ;
input num commax32. ;
cards;
3456
-4567
456,8
;
ok,
yes it works!!!
Thanks Tom.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.