- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Could someone help me solve this problem:
I would like SAS to read the dataset below but I got an error message(posted below): Invalid
data check;
infile cards truncover;
input id ikey acode;
cards;
os1 1 990005
os1 1 9900021
os1 1 211700
os1 2 211700
os1 2 9900021
os1 2 210701
os1 2 990005
os2 2 9900021
os2 1 210701
os2 1 990005
os2 2 9900021
os2 3 210701
os2 3 990005
os3 3 210701
os3 1 211700
os4 1 210701
os4 1 990005
os4 1 211700
;
Thanks in advance
ak.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Your ID variable is alphanumeric and so can only be read as a character, which means you would need to indicate(tell sas) to read a char with a $ sign following the variable name. So, correct your input statement to
input id $ ikey acode;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Your ID variable is alphanumeric and so can only be read as a character, which means you would need to indicate(tell sas) to read a char with a $ sign following the variable name. So, correct your input statement to
input id $ ikey acode;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Review your input statement. Id needs to be read as a character.
input id $ ikey acode;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I would greatly appreciate if someone help me resolve this problem. I had an invalid data reading message in SAS. I tried several reading options but I still had errors.
The code and log are found below. May I know the correct statement to use?
Thanks in advance.
data idnew2;
infile cards;
length id $3 ikey 8 acode presence 8;
input id$ 1-8 ikey acode presence;
input id$ ikey acode presence;
datalines;
os1 1 990005 1
os1 1 9900021 0
os1 1 211700 0
os1 2 211700 0
os1 2 9900021 0
os1 2 210701 0
os1 2 990005 1
os2 1 210701 0
os2 1 990005 1
os2 2 9900021 0
os2 3 210701 0
os2 3 990005 1
os3 1 211700 0
os3 3 210701 0
os4 1 210701 0
os4 1 990005 1
os4 1 211700 0
;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Your ID value contains values that are not numeric. You need to tell SAS the variable is to be read as character or it assumes numeric.
input id $ ikey acode;
The $ after the variable tells SAS to expect a character value of up to 8 characters in length.
If you need to read longer values you will need to either provide information prior to the input statement as to the length of the variable or specify and informat on the input statement to read longer values such as
input id $12. ikey acode;
Note the . after the 12 that helps SAS know that you mean an informat in this case.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks very much. It works now!
ak.