BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MRDM
Obsidian | Level 7

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

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.

SAS Hackathon registration is open! Build your skills. Make connections. Enjoy creative freedom. Maybe change the world.

View solution in original post

2 REPLIES 2
ChrisHemedinger
Community Manager

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.

SAS Hackathon registration is open! Build your skills. Make connections. Enjoy creative freedom. Maybe change the world.
MRDM
Obsidian | Level 7

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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to connect to databases in SAS Viya

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.

Discussion stats
  • 2 replies
  • 1667 views
  • 0 likes
  • 2 in conversation