2
votes

I´m trying to import some dat file (comma delimited) to SAS University. However, one variable contains special characters (e.g. french accents). Most are replaced with �, but also some observations have some problems.

Example of a problem:

An original observation in the data looks like this:

Crème Brûlée,105,280

Running the following command:

DATA BenAndJerrys;
    INFILE '/folders/myfolders/HW3/BenAndJerrys.dat' DLM = ',' DSD MISSOVER;
    INPUT flavor_name :$48. portion_size calories;
RUN;

It has this problem:

flavor_name=Cr�me Br�l�e,105 portion_size=280 calories=

as you can see the value 105 which is the value of portion_size is merged with the value of flavor_name, and the value 280 of calories is assigned to portion_size.

How can solve this problem and allow SAS to import the data with the special characters?

1

1 Answers

2
votes

Try telling SAS what encoding to use when reading the file.

I copied and saved your sample line into a text file using Windows NOTEPAD editor.

%let path=C:\Downloads ;
data _null_;
  infile "&path\test.txt" dsd encoding=wlatin1;
  length x1-x3 $50 ;
  input x1-x3;
  put (_all_) (=);
run;

Result in the log.

x1=Crème Brûlée x2=105 x3=280
NOTE: 1 record was read from the infile "C:\Downloads\test.txt".
      The minimum record length was 20.
      The maximum record length was 20.