Truce
Truce

Reputation: 11

dealing with missing values input file

I need to input a database with delimiter dlm="*" like this:

Abatucci Pierre*Derniers rayons*1200*1*55*84*5
Abatucci Pierre*L'entrée au château*1000*1*75*91

and it works fine like this:

Data  ProjSas.Artiste1;
Infile "C:\Users\Gila\Desktop\StatOrdinL2020\artiste1.txt" dlm="*";
    LENGTH Artiste $ 25 titre $30;                  
Input Artiste $ Titre  Prix  Deces  Hauteur   Largeur  Medium;
      Run;

but in some entries I have missing values like this...(after the 7000)

Beauquesne Wilfrid*Combat d'escorte dans les rues de Verdun*7000**82*100*5

so that value is skipped and the 82 is put in the wrong place and so are the following values.

Upvotes: 1

Views: 157

Answers (2)

Robbie Liu
Robbie Liu

Reputation: 1511

or you can just use proc import if you already have column names included in the source text file

proc import datafile="C:\Users\Gila\Desktop\StatOrdinL2020\artiste1.txt"
 out=ProjSas.Artiste1 dbms=dlm;
 delimiter='*';
 getnames=yes;
  run;

Upvotes: 1

Jay Corbett
Jay Corbett

Reputation: 28441

Add the DSD option to your INFILE statement (How do I read a delimited file in SAS?)

Infile "C:\Users\Gila\Desktop\StatOrdinL2020\artiste1.txt" dlm="*" DSD;

Upvotes: 2

Related Questions