DATA Step, Macro, Functions and more

proc import csv

Reply
Contributor
Posts: 71

proc import csv

Is there a way to tell the system which variable to read as character & which one as numeric/date. I have one numeric column with 13 digits, if I mention getnames=yes in proc import then it makes that column as numeric but values are junk. If I mention getnames=no in proc then it makes that as text.

Ideally I want it numeric with 13 digits but if that is not possible then I want it as text but with getnames.... Please send your expert advice........

Super User
Posts: 17,829

Re: proc import csv

You can't specify types with PROC IMPORT. 

getnames should not make a difference. If you have column headers then use getnames, otherwise don't. 

 

When you run proc import, check your log. It will have the data step code required to read the file. 

Copy the code and modify as necessary to meet your requirements. 

Super User
Super User
Posts: 7,401

Re: proc import csv

Yes, to add to what @Reeza has stated, proc import is a "guessing" procedure, it guesses what your data is.  On the other you know what your data is.  So who is best placed to define how the data should be imported?  You are.  You write the program, based on your import agreement (you do have one of those don't you), that imports the data in exact format/lengths - ejecting invalid data - and is then validated per your import process.

The emphasis at the end of the day is thay you are the data owner, therefore it is your responsibility for it.

Ask a Question
Discussion stats
  • 2 replies
  • 152 views
  • 1 like
  • 3 in conversation