Hello,
I encountered a problem that I couldn't understand. I have a sas program to read a file into sas, which contains number fields that have single character values as missing value. In my program, I didnt' specify "missing A D; " statement, but the program read the value of 'A', and 'D', and create a sas dataset with the value of 'A', 'D', there is no errro message in the log file. I am using SAS 9.4. I am just wondering if SAS 9.4 automatically convert character value for numeric field as missing value or not. Thanks.
Xiumei
There are 28 missing values: .A - .Z and . and also ._
.NA is not defined. The MISSING statement is used to read A-Z and _ as numeric missing values.
It does not work for me.
data x;
input a d;
cards;
1 2
A D
3 4
;
proc print; run;
Obs a d
1 1 2
2 . .
3 3 4
Almost certainly, your new variable is character not numeric. You can run a PROC CONTENTS to find out.
Hello,
Thanks for your prompt reply. But the variable is number, not character.
Xiumei
There are various places that the MISSING option can be specified:
Have you checked them all?
It wouldn't hurt to post the log from your DATA step.
When reading a text file (not a dataset) SAS does not convert character data into special missing values, unless you use the missing statement. It will however convert character data into normal missing values without generating an error message if the ?? modifier is used in conjunction with the informat in the input statement.
Hello,
Thanks for all the replies, but please see my program below, and data file has been attached.
filename data1 'try.txt';
data data1;
infile data1 LRECL=4096 dlm='|' missover dsd;
informat pcr98 $CHAR32. ;
input ID glucose3 tchol3 hdl3 ldl3 trig3 pcr98 $ ;
label ID="participant id number"
glucose3="Glucose"
tchol3="Total cholesterol"
hdl3="HDL"
ldl3="LDL"
trig3="Triglycerides"
pcr98="completed by:";
run;
proc print data=data1;
run;
proc contents data=data1;
run;
The variables here glucode3, tchol3, hdl3, ldl3 are all number fields, but in the data file, there are values of ".D", ".U". Without specifying "MISSING" statement, sas reads these value into the dataset. When I use proc freq, these values are considered as missing values. My qestion is why SAS didn't give any error messages in the log file. thanks.
xiumei
Because .D and .U are missing values in SAS.
Any .A-.Z is considered missing by default and SAS treats data that's in that format as missing.
You should provide a sample of the data file and exactly how you read it into SAS.
Post the code and example data into a code box opened with the forum {i} menu icon.
If you see values of A and D then it is most likely that the variable is not actually numeric but character. The exception would be if you were reading data using a custom informat that assigns special missing values of .A .D or similar.
proc format library=work; invalue someinput 1 - 10=_same_ "A" = .A "D" = .D ; run; data example; informat x someinput.; input x; datalines; 1 2 A 3 D 4 5 ; run;
If you look at the data in a SAS table viewer you will see A and D for a numeric variable
But:
proc freq data=example; run;
Shows the values are missing.
Now it becomes clear.
Your data doesn't contain A and D. It contains .A and .D instead, which SAS understands as numeric.
Sorry, I don't understand, why does sas understand ".A", ".D" as numeric? then how about ".NA"? Thanks.
Xiumei
Here's the SAS documentation chapters on MISSING.
It's worth a read:
Astounding is correct. Compare what you asked (line 2 of the data) with what you did (line 1 of the data).
data x;
input a d;
cards;
.A .D
A D
3 4
;
proc print; run;
Obs a d
1 A D
2 . .
3 3 4
There are 28 missing values: .A - .Z and . and also ._
.NA is not defined. The MISSING statement is used to read A-Z and _ as numeric missing values.
Thanks for the reply. Now I understand for .A-.Z, ._, no need to specify "MISSING" statement in SAS program, sas will consider these values as missing, but for A-Z, MISSING statement need to specified delibrately in sas program, such as MISSING A D. Thanks again!
Xiumei
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.