Hi,
I'm writing out a delimited file and one of the fields contains the value ó, however when I read the file back in it's being read in as ó, I've also tried ø which comes in as ø any ideas? Simplified code:
data &_OUTPUT.;
length UNIQUE_REFERENCE $250.;
infile "&filename." dlm=',' dsd eov=eov truncover firstobs=2;
input UNIQUE_REFERENCE $;
eov=0;
run;
Data is basically
ID56453óHELPME
It's reading everything in correctly except that character.
Essentially my issue is that I need to concatenate two ID fields into the UNIQUE_REFERENCE field, it's then sent off to another system (with loads of other fields) that does some stuff then sends me it back, I then split my UNIQUE_REFERENCE back into my two ID fields. The lengths can vary so I can't use a scan or anything like that, the other system also strips out any special characters which limits my option for a delimiter. I also can't use anything common that might appear in a user entered ID. That leaves me with limited options, ó and ø is an example of a character that it can pass back to me, unfortunately it seems SAS can happily write that out to a file, but reading it in it is converting it to ó and ø using the code above, any ideas? Thanks
Check the encoding of the file -- and add an encoding= option to your INFILE statement.
The SAS session encoding might be different than your file encoding. So an explicit encoding spec might help.
Check the encoding of the file -- and add an encoding= option to your INFILE statement.
The SAS session encoding might be different than your file encoding. So an explicit encoding spec might help.
Thanks, that wouldn't have occurred to me, I checked the encoding with Notepad++ and forced it to UTF-8 and it reads in fine now, it seems SAS (or ours, defaults to DOS as the encoding). Only small issue is if you alter the file, it changes the encoding then trying to read it results in a fatal error. That should be ok though as people shouldn't be altering the files manually.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.