dateimportsasproc

SAS proc import imports date with dots at random place. How can I solve this problem?


I've been trying to import a csv dataset to sas, but, while it imports it correctly on colleagues computer, on mine, the date of birth are imported in a weird format, for ex.: 23.102.023 instead of 23/10/2023.

I used a classic proc import (which works for colleagues):

proc import
    file="filepathandname.csv"
    out=name
    dbms=dlm
    replace;
    delimiter=";";
    getnames=yes;
   run;

What can I do?


Solution

  • Whether or not XX.XX.XXXX is seen as a DATE or a NUMBER by PROC IMPORT will depend on your setting of the system option LOCALE.

    Let's conduct an experiment. Let's make a simple CSV file and read it with PROC IMPORT using both LOCALE=EN_US and LOCALE=IT_IT.

    options parmcards=csv;
    filename csv temp;
    parmcards4;
    id,date
    1,23.10.2023
    ;;;;
    
    options locale=IT_IT;
    proc import file=csv dbms=csv out=import_IT replace;
    run;
    options locale=EN_US;
    proc import file=csv dbms=csv out=import_US replace;
    run;
    

    Note if you want another tool for guessing how a CSV should be read try the %CSV2DS macro as it will recognize DD.MM.YYYY strings as being date values whatever your LOCALE setting is.

    enter image description here