Reading data from txt file

Accepted Solution Solved
Reply
Contributor
Posts: 27
Accepted Solution

Reading data from txt file

Hello 

 

I am trying to read data from a text file. When I did that using the statement below I got notes saying 'invalid data for xyz variable'; I went back to the txt file and they had missing values. Is there any way I can tell SAS to ignore the observations w/ missing values or just get a summary of how many of those have missing values instead of getting notes for each case? The two variables I had missing values are: DTFSPNTC and DLNRMNBG 

 


data selected;
infile bb missover;
input @1 caseid 6.
@172 dob mmddyy8.
@414 age 2.
@1567 DTFSPNTC mmddyy8.
@1672 DLNRMNBG mmddyy8.
@1749 weight 4.
@1759 multiple 1.;

format dob date9.
DTFSPNTC date9.
DLNRMNBG date9.;

run;

 

 

Thank you!

 

 




Accepted Solutions
Solution
‎10-20-2017 12:18 PM
SAS Super FREQ
Posts: 806

Re: Reading data from txt file

You can use the ?? modifier to suppress the note on the invalid data, see sample below

 

data want;
  infile cards;
  input
    @1 someDate ?? mmddyy8.
    @10 someDate2 mmddyy8.
    @19 someChar $3.
  ;
  format someDate: date9.;
cards;
09112017 11092017 abc
         11102017 def
22112017 11112017 ghi
;

View solution in original post


All Replies
Solution
‎10-20-2017 12:18 PM
SAS Super FREQ
Posts: 806

Re: Reading data from txt file

You can use the ?? modifier to suppress the note on the invalid data, see sample below

 

data want;
  infile cards;
  input
    @1 someDate ?? mmddyy8.
    @10 someDate2 mmddyy8.
    @19 someChar $3.
  ;
  format someDate: date9.;
cards;
09112017 11092017 abc
         11102017 def
22112017 11112017 ghi
;
SAS Super FREQ
Posts: 496

Re: Reading data from txt file

SAS does not print a note when it encounters missing values in an input data set.  You must have something else going on like character strings where SAS is expecting numeric values.

 


data x; input x; datalines;
.
;
proc print; run;
9    +data x; input x; datalines;
11   +;
NOTE: The data set WORK.X has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      
☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 101 views
  • 0 likes
  • 3 in conversation