Hello Everybody,
having read the SAS Documentation of the MISSING Statement ,I wanted to replace the special charachter "#" (hash) in a numeric variable with the default value "." :
data survey;
missing '#';
input id answer;
datalines;
001 2
002 #
003 1
004 #
005 2
;
run;
However, I do get the following error:
ERROR 36-169: '#' is an invalid special missing value. Only letters A through Z and _ can be used.
In my original data step I am using an infile statement with the missover option , but there I cannot "tell" SAS what sort of missing value, i.e. "#", it has to interpret.
Another more complicating fact to it, is the possibilty that the representation of the missing value in the data which has to be read in can be varying, i.e. "#" or "##" or "##(blank)##".
The most elegant way which I am looking for, is to tell the infile statement the special characters, that represent a missing value.
Otherwise, I can only see a solution along the lines of using if...then... else if... constructs or using an select statement.
Can anyone help me out?
Thank you in advance.
If your answer variable is numerical then below will work and set any source string to missing that can't get converted to a numerical value.
data survey;
infile datalines truncover dsd dlm=' ';
input id answer ?? :f16.;
datalines;
001 2
002 #
003 1
004 #
005 2
;
run;
btw: The term "special missings" means something else in the SAS world. It's how SAS stores missings in a numerical variable. It's not often used and only useful in conjunction with certain procedures.
If your answer variable is numerical then below will work and set any source string to missing that can't get converted to a numerical value.
data survey;
infile datalines truncover dsd dlm=' ';
input id answer ?? :f16.;
datalines;
001 2
002 #
003 1
004 #
005 2
;
run;
btw: The term "special missings" means something else in the SAS world. It's how SAS stores missings in a numerical variable. It's not often used and only useful in conjunction with certain procedures.
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.