DATA Step, Macro, Functions and more

importing data from a csv, null field

Accepted Solution Solved
Reply
Contributor
Posts: 33
Accepted Solution

importing data from a csv, null field

Hello,

So, I have to import data from a csv file in pretty good shape to a new SAS table.

In a data step I set up INFORMATs FORMATs and the INPUT statement. The file is imported correctly the only problem is that instead of just missing values (as in ,,) some field have ,null, as a value between separators. That particular variable will be numeric so when on that value I give a numeric INFORMAT (like BEST2. since there are 2 digits numbers where there isn't null) the log shout at me "invalid data".

Take notice that the resulting table is correct, in that particular field I have, as I should, the period.

How can I resolve the warnings?


Accepted Solutions
Solution
‎10-11-2016 09:25 AM
Super User
Posts: 6,928

Re: importing data from a csv, null field

You could create a custom format:

proc format library=work;
invalue testfmt
 'null' = .
  other=best.
;
run;

data test;
input x1 testfmt.;
cards;
null
1
2
0
.
;
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎10-11-2016 09:25 AM
Super User
Posts: 6,928

Re: importing data from a csv, null field

You could create a custom format:

proc format library=work;
invalue testfmt
 'null' = .
  other=best.
;
run;

data test;
input x1 testfmt.;
cards;
null
1
2
0
.
;
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 33

Re: importing data from a csv, null field

Didn't think of that, thanks!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 266 views
  • 1 like
  • 2 in conversation