cmdsasdiacritics

SAS: Read file names (DOS) with umlauts


GOAL:

PROBLEM a) when file or folder names contain umlauts the recorded names do not equal the real file names b) even the same umlauts (see picture "ü") are sometimes displayed differently.

Files in Explorer and in SAS-Output

This is my last attempt, using SAS to create the dirrectory listing and to import it directly in SAS. SAS-CODE

filename DIRLIST pipe "dir C:\Z_Backup\LwX\SAS\FilingList\UMLAUTE\ /s";

DATA database ;
     length RawOutput $256 ;
     infile dirlist length=reclen;
     input RawOutput $varying256. reclen ;
RUN;

PROC PRINT; RUN; 

It does not matter, if I create the listing directly in the console and import the rcreated text-file or if I do all in SAS.


Solution

  • Thank you for the valuable comments.

    I solved the issue differently: Instead of reading the directory with SAS, I write a batch-file using SAS. The batch contains the command to change the code page

       C:\>chcp 1252
       Aktive Codepage: 1252.
    

    The text file then contains the correct umlauts and can be imported by SAS without problems.

    Here the respective SAS code:

    * Create Batch; 
    DATA batch; 
        INFORMAT LINE $300.;output;
        Line="chcp 1252 ";output;
        Line="dir &RootStudy. /s >> &DirFilingListDOS.&Akronym._Dateiliste.txt"; output;
        Line="exit"; output; * exit the dos-mode and return to SAS; 
    RUN;    
    
    * Export Batch; 
    DATA _null_;    SET batch;
        file "&DirFilingListDOS.Create_Dir_&Akronym..bat";
        put Line ;
    RUN;
    
    *Start Batch; 
    X "&DirFilingListDOS.Create_Dir_&Akronym..bat";